How to add context menu with VSCode extension?

核能气质少年 提交于 2019-12-19 05:48:13

问题


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

That's based on:

https://github.com/Microsoft/vscode/issues/3192

https://github.com/Microsoft/vscode/pull/7704


回答1:


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"
      }]
    }
  },


来源:https://stackoverflow.com/questions/41400280/how-to-add-context-menu-with-vscode-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!