Skip to content

Commit

Permalink
Merge pull request #620 from elliot-nelson/enelson/reporter
Browse files Browse the repository at this point in the history
fix(fullReporter): Fix off-by-one display issue
  • Loading branch information
ivogabe authored Nov 10, 2019
2 parents 9a3f8d0 + 4023a97 commit e006f9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function fullReporter(fullFilename: boolean = false): Reporter {
const logLine = (lineIndex: number, errorStart: number, errorEnd?: number) => {
const line = lines[lineIndex];
if (errorEnd === undefined) errorEnd = line.length;
console.log('> ' + colors.gray('[' + lineIndex + '] ')
console.log('> ' + colors.gray('[' + (lineIndex + 1) + '] ')
+ line.substring(0, errorStart)
+ colors.red(line.substring(errorStart, errorEnd))
+ line.substring(errorEnd)
Expand All @@ -141,8 +141,8 @@ export function fullReporter(fullFilename: boolean = false): Reporter {

for (let i = error.startPosition.line; i <= error.endPosition.line; i++) {
logLine(i,
i === error.startPosition.line ? error.startPosition.character - 1 : 0,
i === error.endPosition.line ? error.endPosition.character - 1 : undefined
i === error.startPosition.line ? error.startPosition.character : 0,
i === error.endPosition.line ? error.endPosition.character : undefined
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions release/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ function fullReporter(fullFilename = false) {
const line = lines[lineIndex];
if (errorEnd === undefined)
errorEnd = line.length;
console.log('> ' + colors.gray('[' + lineIndex + '] ')
console.log('> ' + colors.gray('[' + (lineIndex + 1) + '] ')
+ line.substring(0, errorStart)
+ colors.red(line.substring(errorStart, errorEnd))
+ line.substring(errorEnd));
};
for (let i = error.startPosition.line; i <= error.endPosition.line; i++) {
logLine(i, i === error.startPosition.line ? error.startPosition.character - 1 : 0, i === error.endPosition.line ? error.endPosition.character - 1 : undefined);
logLine(i, i === error.startPosition.line ? error.startPosition.character : 0, i === error.endPosition.line ? error.endPosition.character : undefined);
}
}
},
Expand Down

0 comments on commit e006f9b

Please sign in to comment.