Skip to content

Commit 87f20fa

Browse files
authored
fix: Fix source map column numbers being off by one (#1458)
1 parent 543ce1a commit 87f20fa

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/ast.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1580,10 +1580,10 @@ export class Source extends Node {
15801580
/** Cached line starts. */
15811581
private lineCache: i32[] | null = null;
15821582

1583-
/** Rememberd column number. */
1584-
private lineColumn: i32 = 0;
1583+
/** Remembered column number. */
1584+
private lineColumn: i32 = 1;
15851585

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

1615-
/** Gets the column number at the last position queried with `lineAt`. */
1615+
/** Gets the column number at the last position queried with `lineAt`. Starts at `1`. */
16161616
columnAt(): i32 {
16171617
return this.lineColumn;
16181618
}

src/program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3627,7 +3627,7 @@ export class Function extends TypedElement {
36273627
range.debugInfoRef,
36283628
source.debugInfoIndex,
36293629
source.lineAt(range.start),
3630-
source.columnAt()
3630+
source.columnAt() - 1 // source maps are 0-based
36313631
);
36323632
}
36333633
}

0 commit comments

Comments
 (0)