Skip to content

Commit ff5595e

Browse files
committed
frontend: Highlight first, not last error in line
We highlight the offending token with an error message, but due to the limited data structure (don't feel like refactoring now, plus performance is already an issue) - we only allow for one token highlight per error lines. Typically the first error is the most meaningful, whereas later errors are sometimes just follow-ons - so only highlight the first error.
1 parent 65b47af commit ff5595e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

frontend/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ function jsError(ptr, len) {
120120
const errorLines = {}
121121
for (const err of errs) {
122122
const g = err.match(re).groups
123-
errorLines[g.line] = { col: g.col, text: lines[g.line - 1] }
123+
if (!errorLines[g.line]) {
124+
errorLines[g.line] = { col: g.col, text: lines[g.line - 1] }
125+
}
124126
msgs += `line ${g.line}: ${g.msg}\n`
125127
}
126128
const output = document.querySelector("#console")

0 commit comments

Comments
 (0)