Reputation: 17553
In VS Code's quick view you can type #mySymbol
to search your workspace for a symbol named mySymbol
. I'd like to get these symbol results programmatically but don't see a way via the API to do so. Any ideas?
Upvotes: 9
Views: 2500
Reputation: 34148
You can run the vscode.executeWorkspaceSymbolProvider
command for this:
vscode.executeWorkspaceSymbolProvider
- Execute all workspace symbol provider.
- query - Search string
- (returns) - A promise that resolves to an array of SymbolInformation instances.
vscode.commands.executeCommand("vscode.executeWorkspaceSymbolProvider", "mySymbol").then(
function (symbols: vscode.SymbolInformation[]) {
// do something with the symbols
}
);
Note that some symbol provider implementations may not return any results if the search query is an empty string.
Upvotes: 8