From 3db7480a4d54684ec7f24d1ae1bcdae6c285511d Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 26 Oct 2020 19:05:00 -0400 Subject: Display multiple error sources if they are on the same line --- docs/repl.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/repl.js b/docs/repl.js index cb3ec52e..da06e383 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -14,14 +14,19 @@ let repl = ()=>{ try { doc.rslt.textContent=fmt(bqn(s)); } catch(e) { - let r=e.src, w=e.message, i=-1; - if (r==='Compiler'&&w.sh[0]===2) [i,w]=w; + let r=e.src, w=e.message, is=null; + if (r==='Compiler'&&w.sh[0]===2) [is,w]=w; if (r==='!') w=w?fmt(w).replace(/^/gm,'! '):'! Error'; else w=w.sh?w.join(''):w; - if (i>=0) { + if (is!==null) { + let n=is.sh?is.sh[0]:0, i=n?is[0]:is; let to=i=>Array.from(s).slice(0,i).join('').split('\n'); - let ll=to(i), l=ll.length-1, j=ll[l].length; - w = [w,'',to()[l],' '.repeat(j)+'^'].join('\n'); + 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('')].join('\n'); + if (k