Skip to content

Commit 7af364c

Browse files
misterflippyprantlf
authored andcommitted
fix: Update newline replacement regex to show correct error position on Windows
1 parent 993b54b commit 7af364c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarks/fail.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ function getLineAndColumn (offset) {
6161
function pastInput ({ offset }) {
6262
const start = Math.max(0, offset - 20)
6363
const previous = inputSource.substr(start, offset - start)
64-
return (offset > 20 ? '...' : '') + previous.replace(/\n/g, '')
64+
return (offset > 20 ? '...' : '') + previous.replace(/\r?\n/g, '')
6565
}
6666

6767
function upcomingInput ({ offset }) {
6868
let start = Math.max(0, offset - 20)
6969
start += offset - start
7070
const rest = inputSource.length - start
7171
const next = inputSource.substr(start, Math.min(20, rest))
72-
return next.replace(/\n/g, '') + (rest > 20 ? '...' : '')
72+
return next.replace(/\r?\n/g, '') + (rest > 20 ? '...' : '')
7373
}
7474

7575
function showPosition ({ offset }) {

0 commit comments

Comments
 (0)