aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-17 21:41:04 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-02-17 21:52:30 -0500
commit3937808e13851e2e0b6346a752dbe5e49a15d27b (patch)
treecd311b73b776591060cfcddf4233ad5295ffcf5c /docs
parentb877e450b2814c51693f32b9e1f1f33538ef6081 (diff)
Fix formatting of error locations that meet or overlap
Diffstat (limited to 'docs')
-rw-r--r--docs/bqn.js2
-rw-r--r--docs/repl.js8
2 files changed, 5 insertions, 5 deletions
diff --git a/docs/bqn.js b/docs/bqn.js
index 5f487e21..a2aa7f58 100644
--- a/docs/bqn.js
+++ b/docs/bqn.js
@@ -501,7 +501,7 @@ let fmtErr = e => {
let k=1,o=i-j,cl=j; while (k<n&&(cl=is[k]-o)<m.length) k++;
let ol=k<n; if (pair) { if (k%2) cl=m.length; else { cl=is[--k]-o+1; } }
let c=Array(cl).fill(0); c[j]=1;
- for (let h=1;h<k;h++) c[is[h]-o+(pair?h%2:0)]=1;
+ for (let h=1;h<k;h++) c[j=Math.max(j,is[h]-o+(pair?h%2:0))]^=1;
if (pair) for (let h=1;h<cl;h++) c[h]^=c[h-1];
let add = ['',m.join(''),c.map(t=>t?'^':' ').join('')];
loc = add.concat(ol?['(and other lines)']:[], loc);
diff --git a/docs/repl.js b/docs/repl.js
index 501d3b61..79e5781b 100644
--- a/docs/repl.js
+++ b/docs/repl.js
@@ -111,11 +111,11 @@ let highlightErr = (s, e) => {
if (!is.sh) { n=1; is=[is]; }
else { n=is.sh[0]; pair=is.sh.length>1; if(pair)n*=2; }
let l=0, sl = j=>s.slice(l,l=j).join('');
- for (let i=0; i<n; i) {
- h.append(sl(is[i++]));
+ for (let i=0; i<n; ) {
+ let b=is[i++]; h.append(sl(b));
+ if (pair) for (b=is[i++]; i<n&&b+1>=is[i]; i+=2) b=is[i+1];
let m = document.createElement('mark');
- m.innerText = sl((pair?is[i++]:l)+1);
- h.append(m);
+ m.innerText = sl(b+1); h.append(m);
}
h.append(sl());
}