Skip to content

Commit 9d55d57

Browse files
committed
ensure starting position is not greater than end position
1 parent bcc4eab commit 9d55d57

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dictionary/build.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ function displayError(
7676
const nextLine = index === -1 ? source.length : index + 1;
7777
const line = source.slice(currentLine, nextLine).trimEnd();
7878
console.error(line);
79-
let relativeStart = currentPosition - currentLine;
79+
let relativeStart = Math.min(
80+
currentPosition - currentLine,
81+
line.length,
82+
);
8083
let relativeEnd = Math.min(end - currentLine, line.length);
8184
if (relativeEnd - relativeStart === 0) {
8285
if (relativeStart !== 0) {

0 commit comments

Comments
 (0)