代码之家  ›  专栏  ›  技术社区  ›  gatapia

VS代码扩展-传播捕获的密钥绑定

  •  0
  • gatapia  · 技术社区  · 7 年前

    在自定义扩展中,我想向“tab”键添加一个命令。但是,我不想阻止“tab”键执行其常规任务。

    package.json 看起来像这样:

    "contributes": {
        ...
        "commands": [
                {
                    "command": "command_name"
                    ...
                }
            ],
            "keybindings": [
                {
                    "command": "command_name",
                    "key": "tab",
                    "when": "editorTextFocus && !editorReadonly"
                }   
            ]
    }
    
    这当前捕获“制表符”字符,但会中断自动完成、插入制表符等操作。当然,我可以在命令中手动将\t插入编辑器,但这仍然会中断自动完成。
    1 回复  |  直到 7 年前
        1
  •  1
  •   Alex    7 年前

    类型 "tab" 使用键盘快捷键中的引号查看所有 标签 When

    要排除上下文,请放置 ! 在它之前。排除扩展所需的所有内容。就像这样:

    "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && !inSnippetMode"// ...