如何从VSCode扩展中的脚本动态修改编辑器标题菜单栏?

时间:2018-04-23 09:44:09

标签: typescript visual-studio-code vscode-extensions

有没有办法在编辑器中打开或关闭新文件时动态添加和删除editor title menu options(右上方的 ... 菜单)?

我知道我可以将它添加到package.json但不知道如何在运行时通过JS / TS执行此操作。

"contributes": {
    "menus": {
        "editor/title": [{
            "command": "workbench.openthisfile",
                "group": "workbench"
        }]
    }
}

基本上,我想在编辑器标题菜单中显示当前打开的文件列表。单击文件名将在编辑器中打开它。   行为类似于Visual Studio

enter image description here

有可能实现这个目标吗?

1 个答案:

答案 0 :(得分:0)

因此,我采用了另一种方法,用户可以通过扩展设置启用/禁用菜单栏操作:

"contributes": {
        "configuration": [
            {
                "title": "Shortcut Menu Bar configuration",
                "properties": {
                    "Save active file": {
                        "type": "boolean",
                        "default": false, // user can enable/disable icon
                        "description": "show icon for save active file"
                    },
                    ....

然后在菜单栏图标单击下面的命令中执行,以显示打开的文件列表:

commands.executeCommand('workbench.action.openPreviousRecentlyUsedEditorInGroup').then(function () {
        });