Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening VS Code settings window from extension with specific search query

I am writing a VS Code extension where I want to open the settings window programmatically from my extension. I want the window to already have the search filled out to only show the settings my extension provides, and also a way to select workspace settings vs user settings when opening the window. I know how to run vscode commands from my extension, but I cannot figure out which commands open that window.

like image 485
Thad House Avatar asked Dec 02 '18 20:12

Thad House


2 Answers

You can now pass an argument to the search, e.g.

vscode.commands.executeCommand( 'workbench.action.openSettings', 'editor.formatOnSaveTimeout' );

or

vscode.commands.executeCommand( 'workbench.action.openSettings', '<your extension>' );
like image 55
Nigel Scott Avatar answered Oct 25 '22 18:10

Nigel Scott


You can open the Settings page using:

vscode.commands.executeCommand('workbench.action.openSettings');

And to focus on the search input:

vscode.commands.executeCommand('settings.action.search');

However, I do not believe it's possible to specify a search value, filter by an extension, or choose the scope (user or workspace). You may open a feature request in the GitHub repo.

like image 28
greenharbour Avatar answered Oct 25 '22 19:10

greenharbour