Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix source map column numbers being off by one #1458

Merged
merged 2 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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