[英]Opening the VSC settings window from code
I'm working on a Visual Studio Code extension, where some settings are required for it to work properly.我正在开发 Visual Studio Code 扩展,需要一些设置才能正常工作。 Right now, in case the user has forgotten something, I'm showing a warning message indicating this, and telling them to fix this property
in the settings.现在,如果用户忘记了什么,我会显示一条警告消息来指出这一点,并告诉他们在设置中修复此property
。 I would, however, like to add a button
that opens the settings
page of that property
.但是,我想添加一个button
来打开该property
的settings
页面。
However, after looking around for over an hour, I can't seem to find any support for this in the Api, or anyone else asking this question (which I find a bit weird?).然而,环顾了一个多小时后,我似乎无法在 Api 或任何其他人问这个问题(我觉得有点奇怪?)中找到对此的任何支持。 If it really doesn't exist, I'd still expect at least 1 other person asking this somewhere, but as far as I can see there's absolutely nothing.如果它真的不存在,我仍然希望至少有 1 个其他人在某个地方问这个问题,但据我所知,绝对没有。
Is it possible to open the settings window (preferably even filtering them down to only my extension's properties/the one property that has to be filled in) from code?是否可以从代码中打开设置 window(最好甚至将它们过滤到我的扩展属性/必须填写的一个属性)?
Thanks in advance提前致谢
I found it out myself after digging through the keybinds
window. You can use the following to open the settings
:我在通过键绑定keybinds
进行挖掘后自己发现了它。您可以使用以下命令打开settings
:
vscode.commands.executeCommand("workbench.action.openSettings2");
I did not, however, find how to pass a search query into it to open a specific place in the settings.但是,我没有找到如何将搜索查询传递给它以在设置中打开特定位置。
EDIT: You can use openSettings
& add the search query as an extra argument to executeCommand
.编辑:您可以使用openSettings
并将搜索查询作为额外参数添加到executeCommand
。 For example - if your property is defined as my.extension.property
in package.json
, you can use this:例如 - 如果您的属性在package.json
中定义为my.extension.property
,您可以使用:
vscode.commands.executeCommand("workbench.action.openSettings", "my.extension.property");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.