Skip to content

Commit 8a89fee

Browse files
committed
Bugfix for newline
1 parent e046df1 commit 8a89fee

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/ginger.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ function reporter(context, options = {}) {
7070
.forEach((correction) => {
7171
const index = correction.start;
7272
const originalPosition = source.originalPositionFromIndex(index);
73+
const originalIndex = source.originalIndexFromIndex(index);
7374
const originalRange = [
74-
originalPosition.column,
75-
originalPosition.column + correction.length,
75+
originalIndex,
76+
originalIndex + correction.length,
7677
];
7778

7879
// if range is ignored, skip reporting

test/ginger.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,16 @@ tester.run('ginger', rule, {
5959
},
6060
],
6161
},
62+
{
63+
text: 'This sentence contains\n newline and errror.',
64+
output: 'This sentence contains\n newline and error.',
65+
errors: [
66+
{
67+
message: 'errror -> error',
68+
line: 2,
69+
column: 14,
70+
},
71+
],
72+
},
6273
],
6374
});

0 commit comments

Comments
 (0)