如何使用 Escape 隐藏 Sublime 内联错误(幻影)

And*_*urg 6 sublimetext3

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

{
  "keys": ["escape"],
  "command": "exec",
  "args": {"hide_phantoms_only" : true },
  "context": [ { "key": "phantom_visible", "operator": "equal", "operand": true }],
},
Run Code Online (Sandbox Code Playgroud)

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

Kei*_*all 4

不幸的是,目前 Sublime Text(在撰写本文时,版本 3126)没有可以在键绑定中使用的上下文来告诉何时显示内联构建错误幻象。ST 论坛对此进行了简要讨论,因此未来的版本可能会包含此功能。

与此同时,受这篇文章的启发,我们可能会尝试创建一个不会与默认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 }
    ]
}
Run Code Online (Sandbox Code Playgroud)