From ad1382dbbac0c3c6076c5f11dbb94259d3ec1ec8 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 17 Nov 2020 14:51:12 -0500 Subject: Fix some UTF-16 issues in JS error reporting --- docs/repl.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/repl.js') diff --git a/docs/repl.js b/docs/repl.js index e9181cca..42184d8f 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -11,12 +11,12 @@ let showErr = (s,e)=>{ while (w&&w.loc||(r!=='!'&&w.sh&&w.sh[0]===2)) { let is; [is,w]=w; let n=is.sh?is.sh[0]:0, i=n?is[0]:is; - let to=i=>s.slice(0,i).join('').split('\n'); + let to=i=>s.slice(0,i).join('').split('\n').map(l=>Array.from(l)); let ll=to(i), l=ll.length-1, j=ll[l].length, m=to()[l]; let k=1,o=i-j,cl=j; while (kt?'^':' ').join('')]; + let add = ['',m.join(''),c.map(t=>t?'^':' ').join('')]; loc = add.concat(k{ doc.rslt.textContent=[w].concat(loc).join('\n'); } let repl = ()=>{ - let s=Array.from(doc.code.value); + let s=Array.from(doc.code.value), src=str(s); doc.rslt.classList.remove('err'); doc.rslt.textContent=' '; setExplain(); setcount(s); setTimeout(() => { try { - let src=str(s), c=compile(src,runtime); + let c=compile(src,runtime); setExplain(src,c); doc.rslt.textContent=fmt(run.apply(null,c)); } catch(e) { - showErr(s,e); + showErr(src,e); } }, 0); } -- cgit v1.2.3