【问题标题】:How to hide Sublime inline errors (phantoms) with Escape如何使用 Escape 隐藏 Sublime 内联错误(幻象)
【发布时间】:2017-01-28 13:06:30
【问题描述】:

所以问题是在不覆盖任何其他功能的情况下将其分配给 Escape。我尝试了以下方法,但它不起作用。

{
  "keys": ["escape"],
  "command": "exec",
  "args": {"hide_phantoms_only" : true },
  "context": [ { "key": "phantom_visible", "operator": "equal", "operand": true }],
},

我没有找到任何关于存在哪些上下文键的文档,所以phantom_visible 只是一个猜测。

【问题讨论】:

标签: sublimetext3


【解决方案1】:

不幸的是,目前 Sublime Text(在撰写本文时,构建 3126)没有可以在键绑定中使用的上下文来判断何时显示内联构建错误幻象。这只是简单的discussed in the ST forums,因此未来的构建可能会包含此功能。

同时,受this post 的启发,我们可能会尝试创建一个不会与默认 Esc 行为冲突的键绑定。但值得记住的是,默认键绑定可能会发生变化,因此我们在更新 ST 时需要注意它,看看这是否仍然相关/正确涵盖所有场景:

{ "keys": ["escape"], "command": "exec", "args": { "hide_phantoms_only": true },
    "context":
    [
        // inverse of all the "escape" key contexts found in the Default keybindings
        { "key": "num_selections", "operator": "equal", "operand": 1 },
        { "key": "has_next_field", "operator": "equal", "operand": false },
        { "key": "has_prev_field", "operator": "equal", "operand": false },
        { "key": "panel_visible", "operator": "equal", "operand": false },
        { "key": "overlay_visible", "operator": "equal", "operand": false },
        { "key": "auto_complete_visible", "operator": "equal", "operand": false }
    ]
}

【讨论】:

    【解决方案2】:

    我使用 Package Control 安装 Chain of Command,它允许我为每个上下文执行多个命令。

    当我按下 [esc] 键时,现在面板可见时它会做三件事:

    • 隐藏面板
    • 隐藏红色错误框
    • 杀死正在运行的程序

    这是我的键映射:

    [ 
        { "keys": ["escape"],
            "context": [
                { "key": "panel_visible", "operator": "equal", "operand": true }
                       ],
            "command": "chain",
            "args": {
                "commands": [
                    ["hide_panel", {"cancel": true}],
                    ["exec", {"hide_phantoms_only": true}],
                    ["exec", {"kill": true}]
                ]
            }
        }
    ]
    

    【讨论】:

      猜你喜欢
      • 2021-08-22
      • 2014-07-03
      • 1970-01-01
      • 2010-10-29
      • 2022-07-06
      • 1970-01-01
      • 2014-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多