22

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

Manuel
  • 10,869
  • 14
  • 55
  • 86

1 Answers1

30

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"
      }]
    }
  },
Manuel
  • 10,869
  • 14
  • 55
  • 86