visual-studio-code - 如何添加带有VSCode扩展名的上下文菜单?

标签 visual-studio-code vscode-extensions

如何添加上下文菜单? (在资源管理器和/或编辑器中)

我尝试了以下无效的方法:

{
    "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

  "contributes": {
    "commands": [
      {
          "command": "extension.sayHello",
          "title": "Say Hello"
      }
    ],
      "menus": {
        "explorer/context": [{
            "when": "resourceLangId == javascript",
            "command": "extension.sayHello",
            "group": "YourGroup@1"
      }]
    }
  },

关于visual-studio-code - 如何添加带有VSCode扩展名的上下文菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41400280/

相关文章:

visual-studio-code - VSCode中如何跳转到单词末尾?

visual-studio-code - 错误 : "extension/package.json not found inside zip." when repackaging and installing VSIX

visual-studio-code - 如何在 vscode 中禁用自动刷新?

regex - 多行字符串文字的语法突出显示

azure - 通过 VS Code 编辑 Azure 逻辑应用标准的代码

javascript - 文本未定义 - JavaScript

visual-studio-code - 在没有 Internet 连接的情况下安装 VS-Code 扩展

typescript - Visual Studio Code 从扩展安装扩展

javascript - 使用 JSDoc 时 Visual Studio Code 中的注释突出显示

visual-studio-code - 在扩展中使用 workbench.colorCustomizations?