File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export async function jumpToTagAndOffset(): Promise<void> {
88 }
99 const nameMatch = file . name . match ( / ( .* ) \. ( i n t | m a c ) $ / i) ;
1010 if ( ! nameMatch ) {
11- vscode . window . showWarningMessage ( "Jump to Tag and Offset only supports .int and .mac routines." ) ;
11+ vscode . window . showWarningMessage ( "Jump to Tag and Offset only supports .int and .mac routines." , "Dismiss" ) ;
1212 return ;
1313 }
1414 const document = vscode . window . activeTextEditor ?. document ;
Original file line number Diff line number Diff line change @@ -656,19 +656,25 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
656656 return ;
657657 }
658658 const [ , routine ] = nameMatch ;
659- const line = event . selections [ 0 ] . start . line ;
660659 let label = "" ;
661660 let pos = 0 ;
662- for ( let i = line ; i > 0 ; i -- ) {
663- const labelMatch = document . lineAt ( i ) . text . match ( / ^ ( % ? \w + ) .* / ) ;
664- if ( labelMatch ) {
665- [ , label ] = labelMatch ;
666- break ;
667- }
668- pos ++ ;
669- }
670- event . textEditor . document . getText ;
671- posPanel . text = `${ label } ${ pos > 0 ? "+" + pos : "" } ^${ routine } ` ;
661+ vscode . commands
662+ . executeCommand < vscode . DocumentSymbol [ ] > ( "vscode.executeDocumentSymbolProvider" , document . uri )
663+ . then ( ( symbols ) => {
664+ const cursor = event . selections [ 0 ] . active ;
665+ if ( symbols . length == 0 || cursor . isBefore ( symbols [ 0 ] . range . start ) ) {
666+ pos = cursor . line - 1 ;
667+ } else {
668+ for ( const symbol of symbols ) {
669+ if ( symbol . range . contains ( cursor ) ) {
670+ label = symbol . name ;
671+ pos = cursor . line - symbol . range . start . line ;
672+ break ;
673+ }
674+ }
675+ }
676+ posPanel . text = `${ label } ${ pos > 0 ? "+" + pos : "" } ^${ routine } ` ;
677+ } ) ;
672678 } ) ;
673679
674680 const documentSelector = ( ...list ) =>
You can’t perform that action at this time.
0 commit comments