[英]Custom button is not showing in the VS code editor title menu bar
在一个扩展中,我想添加一个按钮,当它打开一个突触 XML 文档时,在 VS 代码编辑器标题菜单栏中显示。为此,我在 package.json 文件的命令中添加了以下命令,
{
"command": "webview.show",
"title": "Show Diagram",
"category": "Webview",
"icon": {
"light": "./resources/images/icons/design-view.svg",
"dark": "./resources/images/icons/design-view-inverse.svg"
}
}
在 package.json 文件中,我添加了以下编辑器/标题,
"menus": {
"editor/title": [
{
"when": "resourceLangId == SynapseXml",
"command": "webview.show",
"group": "navigation"
}
],
}
但是当我运行扩展并打开一个突触 XML 文档时,它不会在编辑器标题菜单栏中显示该按钮。
此外,我还遵循以下文档, https://code.visualstudio.com/api/references/contribution-points#contributes.menus
如何在 VS 代码编辑器标题菜单栏中显示按钮?
对于仍然有相同问题的任何人:
在我的情况下,使用正确的上下文名称字段 ( editorLangId
) 匹配命令的when
子句中的语言 ID 修复了该问题。
https://code.visualstudio.com/api/references/when-clause-contexts#available-contexts
"menus": {
"editor/title": [
{
"when": "editorLangId == SynapseXml",
"command": "webview.show",
"group": "navigation"
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.