Opening VS Code settings window from extension with specific search query

守給你的承諾、 提交于 2020-05-09 05:22:05

问题


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.


回答1:


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>' );



回答2:


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.



来源:https://stackoverflow.com/questions/53584266/opening-vs-code-settings-window-from-extension-with-specific-search-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!