Sublime Forum

Run "hide_overlay" on escape key?

#1

When I run a goto-line-number (ctrl+g on mac) command or goto-definition (super+r on mac), type a bit (e.g., a line number), and type escape:

– the current ST behavior is to hide the overlay and return the caret to the point it was when the goto command was initiated

– BUT I would actually like the search to stay where it is in the file (e.g., at line number so-and-so, if that’s what I just typed in)

I’ve noticed that if I bind something else than escape to the hide_overlay command, this has the desired behavior; for example

{ "keys": ["alt+r"], "command": "hide_overlay", "context": [
    { "key": "overlay_visible", "operator": "equal", "operand": true},
]},

has the effect of hiding the overlay and keeping the caret in its new position when alt+r is pressed. But if try to bind escape to the same command, via

{ "keys": ["escape"], "command": "hide_overlay", "context": [
    { "key": "overlay_visible", "operator": "equal", "operand": true},
]},

it seems to have no effect, and to revert the above behavior, in which the view returns to its original position and the goto operation is canceled.

Ideally I’d like to have two commands available: one to hide the overlay while abandoning the search and restoring the caret to its original place, and one to hide the overlay while keeping the search. Right now the escape key does the former, while binding anything else to hide_overlay does the latter. But I want the opposite, to bind escape to the latter, and to bind some other key combo to the former (for which I am currently missing a command).

In short I’m missing two things: how to bind escape to the hide_overlay command, and how to have something else have the same effect as escape does right now.

1 Like