aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-16 11:44:13 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-16 11:44:13 -0500
commitb34f894ab1c9ef60b6d994de3687862832e276f2 (patch)
tree95377ac099a52bd3625d97c5012a44148dc43e59
parent9f3348739971eb3e212c36dacbd73b436bf314f7 (diff)
Clear error highlight on running code or using keybar
-rw-r--r--docs/repl.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/docs/repl.js b/docs/repl.js
index 5e891e5c..23e18e63 100644
--- a/docs/repl.js
+++ b/docs/repl.js
@@ -17,11 +17,14 @@ if (doc.count) {
setcount(c.value.slice(s,e), 2);
}
}
+let clearHighlight = doc.code.oninput = () => {
+ doc.highlight.innerText = '';
+}
let setExplain = e=>e;
let repl = () => {
let s=Array.from(doc.code.value), src=str(s);
- doc.rslt.textContent=' '; setExplain();
+ doc.rslt.textContent=' '; setExplain(); clearHighlight();
setcount(s);
setTimeout(() => {
doc.rslt.textContent = '';
@@ -93,13 +96,12 @@ sysvals.setplot = (x,w) => { startPlot(); setPlot(x,w); }
let highlightErr = (s, e) => {
let h = doc.highlight;
h.style.height = doc.code.clientHeight+"px";
- let clear = doc.code.oninput = () => { h.innerText = ''; }
let scroll = doc.code.onscroll = () => {
h.scrollTop = doc.code.scrollTop;
h.scrollLeft = doc.code.scrollLeft;
}
- clear();
+ clearHighlight();
let w=e.message, is;
while (w && (w.loc||(e.kind!=='!'&&w.sh&&w.sh[0]===2))
&& w.src.join('')===s.join('')) { [is,w]=w; }
@@ -140,6 +142,7 @@ doc.code.onkeydown = ev => {
}
}
let typeChar = (t, c, ev) => {
+ clearHighlight();
let v = t.value;
let i = t.selectionStart;
t.value = v.slice(0,i)+c+v.slice(t.selectionEnd);