@@ -325,6 +325,32 @@ export class ShaderVariantTreeDataProvider implements vscode.TreeDataProvider<Sh
325325 this . onDidChangeTreeDataEmitter . fire ( ) ;
326326 this . updateDependencies ( ) ;
327327 }
328+ private requestDocumentSymbol ( uri : vscode . Uri ) {
329+ // This one seems to get symbol from cache without requesting the server...
330+ //vscode.commands.executeCommand("vscode.executeDocumentSymbolProvider", file.uri);
331+ // This one works, but result is not intercepted by vscode & updated...
332+ //this.client.sendRequest(DocumentSymbolRequest.type, {
333+ // textDocument: {
334+ // uri: this.client.code2ProtocolConverter.asUri(file.uri),
335+ // }
336+ //});
337+ // We have to rely on a dirty hack instead.
338+ // Need to check this does not break anything
339+ // Dirty hack to trigger document symbol update
340+ for ( let editor of vscode . window . visibleTextEditors ) {
341+ if ( editor . document . uri . path === uri . path ) {
342+ editor . edit ( editBuilder => {
343+ let line = editor . document . lineAt ( 0 ) ;
344+ const text = line . text ;
345+ const c = line . range . end . character ;
346+ // Remove last character of first line and add it back.
347+ editBuilder . delete ( new vscode . Range ( 0 , c - 1 , 0 , c ) ) ;
348+ editBuilder . insert ( new vscode . Position ( 0 , c ) , text [ c - 1 ] ) ;
349+ } ) ;
350+ break ;
351+ }
352+ }
353+ }
328354 private updateDependency ( file : ShaderVariantFile ) {
329355 let fileActiveVariant = getActiveFileVariant ( file ) ;
330356 let params : DidChangeShaderVariantParams = {
@@ -336,15 +362,7 @@ export class ShaderVariantTreeDataProvider implements vscode.TreeDataProvider<Sh
336362 this . client . sendNotification ( didChangeShaderVariantNotification , params ) ;
337363
338364 // Symbols might have changed, so request them as we use this to compute symbols.
339- // TODO: update vscode symbols for gutter to show.
340- // This one seems to get symbol from cache without requesting the server...
341- //vscode.commands.executeCommand("vscode.executeDocumentSymbolProvider", file.uri);
342- // This one works, but result is not intercepted by vscode & updated...
343- //this.client.sendRequest(DocumentSymbolRequest.type, {
344- // textDocument: {
345- // uri: this.client.code2ProtocolConverter.asUri(file.uri),
346- // }
347- //});
365+ this . requestDocumentSymbol ( file . uri ) ;
348366 }
349367 public onDocumentSymbols ( uri : vscode . Uri , symbols : vscode . SymbolInformation [ ] ) {
350368 this . shaderEntryPointList . set ( uri . path , symbols . filter ( symbol => symbol . kind === vscode . SymbolKind . Function ) . map ( symbol => {
0 commit comments