菜單擴展是通過配置擴展點來註冊的,一般要關聯一個命令。擴展方式是在package.json中contributes節點下增加menus擴展點。相關代碼如下:

    1. "contributes": {
    2. "menus": {
    3. "editor/context": [
    4. {
    5. "command": "extension.helloWorld",
    6. "group": "z_commands",
    7. "when": "editorTextFocus"
    8. },
    9. {
    10. "group": "z_commands"
    11. }
    12. ]
    13. }
    14. }

    菜單擴展點詳細的說明請參考這裏menus