【问题标题】:How to dynamically modify editor title menu bar from script in VSCode extension?如何从 VSCode 扩展中的脚本动态修改编辑器标题菜单栏?
【发布时间】:2018-10-03 07:32:02
【问题描述】:

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

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

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

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

有可能实现吗?

【问题讨论】:

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


    【解决方案1】:

    所以我采用了一种不同的方法,用户可以从扩展设置中启用/禁用菜单栏操作:

    "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 () {
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-04
      • 1970-01-01
      相关资源
      最近更新 更多