@@ -139,12 +139,12 @@ export function activate(context: vscode.ExtensionContext) {
139
139
let cachedSymbols : vscode . DocumentSymbol [ ] = [ ] ;
140
140
let cachedSymbolsDocUri = vscode . Uri . parse ( 'file:/empty' ) ;
141
141
142
- async function getSymbolFromXPath ( args : any [ ] ) {
142
+ async function getSymbolFromXPath ( args : any [ ] , textDocument ?: vscode . TextDocument ) {
143
143
const { xpath, uri } = args [ 0 ] ;
144
144
const docUri = vscode . Uri . parse ( uri ) ;
145
145
const useCachedSymbols = cachedSymbolsDocUri === docUri ;
146
146
const docs = vscode . workspace . textDocuments ;
147
- const foundDoc = docs . find ( doc => doc . uri . toString ( ) === uri ) ;
147
+ const foundDoc = textDocument ? textDocument : docs . find ( doc => doc . uri . toString ( ) === uri ) ;
148
148
if ( ! useCachedSymbols && foundDoc ) {
149
149
const sp = new XsltSymbolProvider ( XMLConfiguration . configuration , null ) ;
150
150
const newSymbols = await sp . getDocumentSymbols ( foundDoc , false ) ;
@@ -165,9 +165,12 @@ export function activate(context: vscode.ExtensionContext) {
165
165
let doc = await vscode . workspace . openTextDocument ( docUri ) ;
166
166
const viewColumn = vscode . ViewColumn . Beside ;
167
167
const keepFocus = true ;
168
- await vscode . window . showTextDocument ( doc , viewColumn , keepFocus ) ;
169
- selectTextFromXPath ( xpath ) ;
170
-
168
+ const editor = await vscode . window . showTextDocument ( doc , viewColumn , keepFocus ) ;
169
+ const symbol = await getSymbolFromXPath ( args , doc ) ;
170
+ if ( symbol ) {
171
+ editor . selection = new vscode . Selection ( symbol . range . start , symbol . range . end ) ;
172
+ XsltSymbolProvider . selectTextWithSymbol ( symbol ) ;
173
+ }
171
174
}
172
175
173
176
context . subscriptions . push ( vscode . window . onDidChangeActiveTextEditor ( editor => {
0 commit comments