Skip to content

Commit

Permalink
fix column computation
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Sep 22, 2016
1 parent a8da925 commit 2ce1973
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/parser/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ var Scanner = function(source, initLine, initColumn) {
this.initLine = typeof initLine === 'undefined' ? 1 : initLine;
this.initColumn = (typeof initColumn === 'undefined' ? 1 : initColumn) - start;
this.lastLocationLine = this.initLine;
this.lastLocationLineOffset = 0;
this.lastLocationLineOffset = 1 - this.initColumn;
this.lines = null;

this.eof = false;
Expand Down Expand Up @@ -345,7 +345,7 @@ Scanner.prototype = {
var lineOffset;

if (line === this.initLine) {
offset += this.initColumn;
column += this.initColumn;
} else {
// try get precomputed line offset
if (line === this.lastLocationLine) {
Expand All @@ -357,7 +357,7 @@ Scanner.prototype = {
this.lastLocationLineOffset = lineOffset;
}

offset -= lineOffset;
column -= lineOffset;
}

return {
Expand Down

0 comments on commit 2ce1973

Please sign in to comment.