File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -707,9 +707,12 @@ async function deriveSourceLocation(
707707
708708 const maintainer = store . maintain ( fileUri ) ;
709709 const mapping = await ( maintainer . value || maintainer . refresh ( ) ) ;
710+ // in parsed stack traces line and column numbers are 1-based, in the VS Code APIs lines are 0-based
711+ const zeroBasedLine = Number ( line ) - 1 ;
712+ const zeroBasedCol = Number ( col ) - 1 ;
710713 const value =
711- mapping ?. originalPositionFor ( Number ( line ) , Number ( col ) ) ||
712- new vscode . Location ( fileUri , new vscode . Position ( Number ( line ) , Number ( col ) ) ) ;
714+ mapping ?. originalPositionFor ( zeroBasedLine , zeroBasedCol ) ||
715+ new vscode . Location ( fileUri , new vscode . Position ( zeroBasedLine , zeroBasedCol ) ) ;
713716
714717 // timeout the maintainer async so that it stays alive for any other immediate teset usage in the file:
715718 setTimeout ( ( ) => maintainer . dispose ( ) , 5000 ) ;
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export const identityMapping = (file: vscode.Uri): IMappingAccessor => ({
3030} ) ;
3131
3232const smMappingAccessor = ( file : vscode . Uri , sm : TraceMap ) : IMappingAccessor => ( {
33+ // @jridgewell /trace-mapping: Lines start at line 1, columns at column 0.
3334 originalPositionFor ( line , column ) {
3435 const {
3536 source,
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ describe('typescript', () => {
8484 expect ( failed . message ?. location ) . to . not . be . undefined ;
8585 expect ( failed . message ?. location ?. uri . toString ( ) ) . to . include ( 'hello.test.ts' ) ;
8686 expect ( path . isAbsolute ( failed . message ! . location ! . uri . fsPath ) ) . to . be . true ;
87- expect ( failed . message ?. location ?. range . start . line ) . to . equal ( 29 ) ;
88- expect ( failed . message ?. location ?. range . start . character ) . to . equal ( 5 ) ;
87+ expect ( failed . message ?. location ?. range . start . line ) . to . equal ( 28 ) ;
88+ expect ( failed . message ?. location ?. range . start . character ) . to . equal ( 4 ) ;
8989 } ) ;
9090} ) ;
You can’t perform that action at this time.
0 commit comments