如何使用 vscode 扩展 api 将命令放入子菜单
How to place a command into a submenu using the vscode extension api
我正在创建一个 Visual studio 代码扩展,我想将命令放入这样的子菜单中
此处,“Peek”子菜单包含“Peek Call Hierarchy”等命令。
目前在我的Package.json
中,我有
{
"contributes": {
"commands": [{
"command":"myExtension.dothing",
"title":"make the extension do a thing",
"category":"myextensioncategory"
}],
"menus": [{
"explorer/context": [{
"command": "myExtension.dothing",
"group": "myextension.myGroup",
"when": "!explorerResourceIsFolder"
},
{
"submenu": "myextensionsubmenu",
"group": "myextension.myGroup"
}
]
}],
"submenus": [{
"label": "my extension",
"id": "myextensionsubmenu"
}]
}
}
(未删除相关部分)
它显示了这样的东西
我想将“让扩展做某事”命令放入“我的扩展”子菜单中,但我不明白如何从 docs
任何人都可以解释或指出 resource/tutorial 吗?
谢谢!
据我了解子菜单的结构,你必须在菜单数组中添加相关条目。
您的 package.json 可能如下所示:
{
"contributes": {
"commands": [{
"command":"myExtension.dothing",
"title":"make the extension do a thing",
"category":"myextensioncategory"
}],
"menus": [{
"explorer/context": [{
"command": "myExtension.dothing",
"group": "myextension.myGroup",
"when": "!explorerResourceIsFolder"
},
{
"submenu": "myextensionsubmenu",
"group": "myextension.myGroup"
}
],
"myextensionsubmenu":[
{
"command":"myExtension.dothing",
"group":"myExtension.myGroup"
}
]
}],
"submenus": [{
"label": "The Label for the menu that opens the submenu",
"id": "myextensionsubmenu"
}]
}
}
“子菜单”数组中的对象似乎只定义了相应条目的标签。
你也可以看看。可能对你有帮助。
我正在创建一个 Visual studio 代码扩展,我想将命令放入这样的子菜单中
此处,“Peek”子菜单包含“Peek Call Hierarchy”等命令。
目前在我的Package.json
中,我有
{
"contributes": {
"commands": [{
"command":"myExtension.dothing",
"title":"make the extension do a thing",
"category":"myextensioncategory"
}],
"menus": [{
"explorer/context": [{
"command": "myExtension.dothing",
"group": "myextension.myGroup",
"when": "!explorerResourceIsFolder"
},
{
"submenu": "myextensionsubmenu",
"group": "myextension.myGroup"
}
]
}],
"submenus": [{
"label": "my extension",
"id": "myextensionsubmenu"
}]
}
}
(未删除相关部分)
它显示了这样的东西
我想将“让扩展做某事”命令放入“我的扩展”子菜单中,但我不明白如何从 docs 任何人都可以解释或指出 resource/tutorial 吗? 谢谢!
据我了解子菜单的结构,你必须在菜单数组中添加相关条目。
您的 package.json 可能如下所示:
{
"contributes": {
"commands": [{
"command":"myExtension.dothing",
"title":"make the extension do a thing",
"category":"myextensioncategory"
}],
"menus": [{
"explorer/context": [{
"command": "myExtension.dothing",
"group": "myextension.myGroup",
"when": "!explorerResourceIsFolder"
},
{
"submenu": "myextensionsubmenu",
"group": "myextension.myGroup"
}
],
"myextensionsubmenu":[
{
"command":"myExtension.dothing",
"group":"myExtension.myGroup"
}
]
}],
"submenus": [{
"label": "The Label for the menu that opens the submenu",
"id": "myextensionsubmenu"
}]
}
}
“子菜单”数组中的对象似乎只定义了相应条目的标签。
你也可以看看