如何使用 VSCode 扩展添加上下文菜单? [英] How to add context menu with VSCode extension?
本文介绍了如何使用 VSCode 扩展添加上下文菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何添加上下文菜单?(在资源管理器和/或编辑器中)
How do you add a context menu? (in the explorer and/or the editor)
我尝试了以下不起作用的方法:
I tried the following which doesn't work:
{
"command": "extension.sayHello",
"title": "Say Hello",
"context": {
"where": "explorer/context",
"when": "json"
}
}
这是基于:
https://github.com/Microsoft/vscode/issues/3192
https://github.com/Microsoft/vscode/pull/7704
推荐答案
extensionAPI 文档有一个工作示例:https://code.visualstudio.com/docs/extensionAPI/extension-points
The extensionAPI documentation has a working example: https://code.visualstudio.com/docs/extensionAPI/extension-points
"contributes": {
"commands": [
{
"command": "extension.sayHello",
"title": "Say Hello"
}
],
"menus": {
"explorer/context": [{
"when": "resourceLangId == javascript",
"command": "extension.sayHello",
"group": "YourGroup@1"
}]
}
},
这篇关于如何使用 VSCode 扩展添加上下文菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文