简体   繁体   English

从代码中打开 VSC 设置 window

[英]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来打开该propertysettings页面。

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.

相关问题 使用特定搜索查询从扩展程序打开 VS Code 设置窗口 - Opening VS Code settings window from extension with specific search query 在 VSC 中打开文件夹时,我可以选择是替换当前窗口还是在新窗口中打开文件夹? - Can I, when opening a folder in VSC, choose whether I replace the current window or open the folder in a new window? 自动自动换行到窗口VSC - Auto wordWrap to the window VSC VSC 平台特定设置 - VSC platform-specific settings 尽管存在 eslint 文件并且设置设置为在保存时修复,VSC 不会格式化代码 - VSC won't format code although eslint file exists and settings are set to fix on save 我可以从 VSC 中的 tasks.json 访问其他 json 文件中定义的设置吗? - Can I access settings defined in other json files from tasks.json in VSC? 当我运行 C 代码时,如何阻止 Visual Studio Code 打开外部终端 window - How to stop Visual Studio Code from opening an external terminal window when I run my C code Visual Studio Code 与 Powershell ISE:在 VSC 的终端 window 中获取 Intellisense 建议弹出窗口? - Visual Studio Code vs Powershell ISE: Getting Intellisense suggestion pop-up in terminal window in VSC? 编辑设置后,VSC中的emmet功能无法正常工作 - emmet features in VSC not working after editing settings 如何关闭在 VSC 中执行时打开的选项卡? - How to turn off tab opening on execution in VSC?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM