Skip to content

Commit fdf296e

Browse files
committed
Merge branch 'misterflippy-fix-newline-replacement'
2 parents 1736ade + 7af364c commit fdf296e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
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 }) {

src/native-parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ function getLineAndColumn (input, offset) {
1313
function pastInput (input, offset) {
1414
var start = Math.max(0, offset - 20)
1515
var previous = input.substr(start, offset - start)
16-
return (offset > 20 ? '...' : '') + previous.replace(/\n/g, '')
16+
return (offset > 20 ? '...' : '') + previous.replace(/\r?\n/g, '')
1717
}
1818

1919
function upcomingInput (input, offset) {
2020
var start = Math.max(0, offset - 20)
2121
start += offset - start
2222
var rest = input.length - start
2323
var next = input.substr(start, Math.min(20, rest))
24-
return next.replace(/\n/g, '') + (rest > 20 ? '...' : '')
24+
return next.replace(/\r?\n/g, '') + (rest > 20 ? '...' : '')
2525
}
2626

2727
function getPositionContext (input, offset) {

0 commit comments

Comments
 (0)