File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Expand file tree Collapse file tree 4 files changed +14
-10
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 @@ -235,8 +235,8 @@ describe('simple', () => {
235235 expect ( failed . message ?. location ) . to . not . be . undefined ;
236236 expect ( failed . message ?. location ?. uri . toString ( ) ) . to . include ( 'hello.test.js' ) ;
237237 expect ( path . isAbsolute ( failed . message ! . location ! . uri . fsPath ) ) . to . be . true ;
238- expect ( failed . message ?. location ?. range . start . line ) . to . equal ( 12 ) ;
239- expect ( failed . message ?. location ?. range . start . character ) . to . equal ( 5 ) ;
238+ expect ( failed . message ?. location ?. range . start . line ) . to . equal ( 11 ) ;
239+ expect ( failed . message ?. location ?. range . start . character ) . to . equal ( 4 ) ;
240240 } ) ;
241241
242242 it ( 'handles file and directory excludes' , async ( ) => {
@@ -318,10 +318,10 @@ describe('simple', () => {
318318 } ) ;
319319
320320 const failed = run . states . find ( ( s ) => s . state === 'failed' ) ;
321- expect ( failed ! . message ! . location ! . range . start . line ) . to . equal ( 4 ) ;
322- expect ( failed ! . message ! . location ! . range . start . character ) . to . equal ( 11 ) ;
323- expect ( failed ! . message ! . location ! . range . end . line ) . to . equal ( 4 ) ;
324- expect ( failed ! . message ! . location ! . range . end . character ) . to . equal ( 11 ) ;
321+ expect ( failed ! . message ! . location ! . range . start . line ) . to . equal ( 3 ) ;
322+ expect ( failed ! . message ! . location ! . range . start . character ) . to . equal ( 10 ) ;
323+ expect ( failed ! . message ! . location ! . range . end . line ) . to . equal ( 3 ) ;
324+ expect ( failed ! . message ! . location ! . range . end . character ) . to . equal ( 10 ) ;
325325 expect ( failed ! . message ! . location ! . uri . fsPath ) . to . equal ( item . uri ! . fsPath ) ;
326326 } ) ;
327327} ) ;
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