微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将保存项添加到 vscode 编辑器上下文菜单

如何解决将保存项添加到 vscode 编辑器上下文菜单

这里是 Vscode 菜鸟,尝试在编辑器上下文菜单获取保存项。我已经做到了:

{
    "name": "vsContextSave","displayName": "vsContextSave","description": "add save item to editor context menu","version": "0.0.0","publisher": "njamescouk","repository": {
        "type": "git","url": ""
    },"license": "MIT License","engines": {
        "vscode": "^1.40.0"
    },"contributes": {
        "menus": {
            "editor/context": [
                {
                    "command": "workbench.action.files.save","group": "9_cutcopypaste","when": "editorTextFocus"
                }
            ]
        }
    },"__Metadata": {}
}

当包含在 .vscode\extensions 目录中的目录中时,vscode 会看到它,并且 vsContextSave 会显示在扩展列表中并被启用。但是我在上下文菜单中没有看到保存项目。

编辑:

我在元数据语句之前插入了一个激活事件,但显然我需要一个带有 activate() 函数的主模块。

"activation Events": ["onStartupFinished"],

解决方法

这两个文件可让您在编辑器中查找、查找文件并另存为上下文菜单项。

extension.js:

不知道这是做什么的,但似乎是必要的

'use strict';
Object.defineProperty(exports,"__esModule",{ value: true });
const vscode = require("vscode");
function activate(context) {
};

package.json:

{
    "name": "mainContext","displayName": "mainContext","description": "add various items to editor context menu","version": "0.0.0","publisher": "njamescouk","repository": {
        "type": "git","url": ""
    },"license": "MIT License","engines": {
        "vscode": "^1.40.0"
    },"main": "./extension.js","contributes": {
        "menus": {
            "editor/context": [
                {
                    "command": "workbench.action.files.save","group": "9_cutcopypaste","when": "editorTextFocus"
                },{
                    "command": "actions.find",{
                    "command": "workbench.action.quickOpen","when": "editorTextFocus"
                }
            ]
        },"commands": [
            {
                "title": "Save","command": "workbench.action.files.save"
            },{
                "title": "Find","command": "actions.find"
            },{
                "title": "Find file","command": "workbench.action.quickOpen"
            }
        ]
    },"activationEvents": [
        "onStartupFinished"
    ],"__metadata": {}
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。