Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide Sublime inline errors (phantoms) with Escape

Tags:

sublimetext3

So the problem is to assign this to Escape without overriding any other functionality. I've tried the following, but it doesn't work.

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

I haven't found any documentation on which context keys exist, so phantom_visible was just a guess.

like image 782
Andreas Haferburg Avatar asked Jan 28 '17 13:01

Andreas Haferburg


1 Answers

Unfortunately, at the moment Sublime Text (at the time of writing, build 3126) does not have a context that you can use in a keybinding to tell when inline build error phantoms are shown. This has been briefly discussed in the ST forums so it is possible that a future build will contain this functionality.

In the meantime, inspired by this post, we could potentially try to create a keybinding that won't conflict with the default Esc behavior. But it's worth bearing in mind that the default keybindings may change so we will need to watch for it when updating ST, to see whether this is still relevant/correctly covers all scenarios:

{ "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 }
    ]
}
like image 154
Keith Hall Avatar answered Oct 15 '22 10:10

Keith Hall