From e03afb1cc481f06e4811c6e126c7c29b521e1da4 Mon Sep 17 00:00:00 2001 From: dcode Date: Fri, 4 Sep 2020 15:19:54 +0200 Subject: [PATCH 1/2] Fix source map column numbers being off by one --- src/ast.ts | 4 ++-- src/program.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index b3b4df6258..76f63253c3 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -1583,7 +1583,7 @@ export class Source extends Node { /** Rememberd column number. */ private lineColumn: i32 = 0; - /** 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; @@ -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; } diff --git a/src/program.ts b/src/program.ts index 63fdf560da..05a020452c 100644 --- a/src/program.ts +++ b/src/program.ts @@ -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 ); } } From 0b59d8d276cb012fbab2d5c199477ce50e1eb65a Mon Sep 17 00:00:00 2001 From: dcode Date: Fri, 4 Sep 2020 15:21:43 +0200 Subject: [PATCH 2/2] update default fwiw, fix typo --- src/ast.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index 76f63253c3..c26c794f8d 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -1580,8 +1580,8 @@ 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. Starts at `1`. */ lineAt(pos: i32): i32 {