Skip to content

Commit

Permalink
fix: Fix source map column numbers being off by one (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored Sep 5, 2020
1 parent 543ce1a commit 87f20fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1580,10 +1580,10 @@ export class Source extends Node {
/** Cached line starts. */
private lineCache: i32[] | null = null;

/** Rememberd column number. */
private lineColumn: i32 = 0;
/** Remembered column number. */
private lineColumn: i32 = 1;

/** Determines the line number at the specified position. */
/** Determines the line number at the specified position. Starts at `1`. */
lineAt(pos: i32): i32 {
assert(pos >= 0 && pos < 0x7fffffff);
var lineCache = this.lineCache;
Expand Down Expand Up @@ -1612,7 +1612,7 @@ export class Source extends Node {
return assert(0);
}

/** Gets the column number at the last position queried with `lineAt`. */
/** Gets the column number at the last position queried with `lineAt`. Starts at `1`. */
columnAt(): i32 {
return this.lineColumn;
}
Expand Down
2 changes: 1 addition & 1 deletion src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3627,7 +3627,7 @@ export class Function extends TypedElement {
range.debugInfoRef,
source.debugInfoIndex,
source.lineAt(range.start),
source.columnAt()
source.columnAt() - 1 // source maps are 0-based
);
}
}
Expand Down

0 comments on commit 87f20fa

Please sign in to comment.