Skip to content

Commit

Permalink
eng: fix off-by-1 error in selfhost test error messages (microsoft#21…
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 authored and mustard-mh committed May 22, 2024
1 parent cd33651 commit cad86b0
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export async function scanTestOutput(
return;
}

const logLocation = store.getSourceLocation(match[2], Number(match[3]));
const logLocation = store.getSourceLocation(match[2], Number(match[3]) - 1);
const logContents = replaceAllLocations(store, match[1]);
const test = currentTest;

Expand Down Expand Up @@ -459,7 +459,8 @@ export class SourceMapStore {
};
}

async getSourceLocation(fileUri: string, line: number, col = 1) {
/** Gets an original location from a base 0 line and column */
async getSourceLocation(fileUri: string, line: number, col = 0) {
return this.getSourceLocationMapper(fileUri).then(m => m(line, col));
}

Expand Down Expand Up @@ -599,5 +600,5 @@ async function tryDeriveStackLocation(

async function deriveSourceLocation(store: SourceMapStore, parts: RegExpMatchArray) {
const [, fileUri, line, col] = parts;
return store.getSourceLocation(fileUri, Number(line), Number(col));
return store.getSourceLocation(fileUri, Number(line) - 1, Number(col));
}

0 comments on commit cad86b0

Please sign in to comment.