Cleanup getLineInfo (#8540)

Removes an ignore control comment
This commit is contained in:
Justin Ridgewell 2018-08-26 13:27:06 -04:00 committed by GitHub
parent 72ee1816a4
commit edbffda091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,16 +39,14 @@ export class SourceLocation {
// into. // into.
export function getLineInfo(input: string, offset: number): Position { export function getLineInfo(input: string, offset: number): Position {
for (let line = 1, cur = 0; ; ) { let line = 1;
lineBreakG.lastIndex = cur; let lineStart = 0;
const match = lineBreakG.exec(input); let match;
if (match && match.index < offset) { lineBreakG.lastIndex = 0;
++line; while ((match = lineBreakG.exec(input)) && match.index < offset) {
cur = match.index + match[0].length; line++;
} else { lineStart = lineBreakG.lastIndex;
return new Position(line, offset - cur);
} }
}
// istanbul ignore next return new Position(line, offset - lineStart);
throw new Error("Unreachable");
} }