Fix location reported by JS parser in case of long lines

This commit is contained in:
Alexey Andreev
2017-05-22 19:36:47 +03:00
parent 1dae687e7d
commit e43cc65702
@@ -236,11 +236,7 @@ final class LineBuffer {
// Get the offset of the current character, relative to // Get the offset of the current character, relative to
// the line that getLine() returns. // the line that getLine() returns.
int getOffset() { int getOffset() {
if (lineStart < 0) return offset - lineStart;
// The line begins somewhere in the other buffer.
return offset + (otherEnd - otherStart);
else
return offset - lineStart;
} }
private boolean fill() throws IOException { private boolean fill() throws IOException {
@@ -269,7 +265,7 @@ final class LineBuffer {
// set lineStart to a sentinel value, unless this is the first // set lineStart to a sentinel value, unless this is the first
// time around. // time around.
prevStart = lineStart = (otherBuffer == null) ? 0 : -1; prevStart = lineStart = (otherBuffer == null) ? 0 : lineStart - end;
offset = 0; offset = 0;
end = in.read(buffer, 0, buffer.length); end = in.read(buffer, 0, buffer.length);