Sublime Forum

Pressing enter/return no longer works in the overlay?

#1

I noticed this in the past week so I think it may be a bug introduced in ST4.

I use keybindings to run commands to goto a specific line in the current file and to open files in the current directory like so:

    {"keys": ["ctrl+t"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
    {"keys": ["ctrl+g"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },

These commands still work, but now when I select which file I want and press “enter”, nothing happens. I have to manually click on it in order to open it. The same problem occurs with going to a specific line: when I press enter nothing happens. When I press escape it just goes back to the file/line I was looking at before.

0 Likes

Open reference in active column
#2

There are a series of new default key bindings added in ST4 for interaction with panels that use the select command for indicating that an item should be chosen from a panel. For example, here’s one of them:

	{ "keys": ["enter"], "command": "select", "context":
		[
			{ "key": "overlay_has_focus", "operator": "equal", "operand": true },
			{ "key": "overlay_name", "operator": "equal", "operand" : "goto" }
		],
	},

In ST3 there were no such bindings because the enter key was hard coded to always enter in a panel.

If you’re seeing this problem, it’s because you have an override on the default key bindings, which locks them into what the defaults were in ST3 and stops this from working.

If you use Preferences: Browse Packages, you will most likely see a folder named Default present; if so, any of the files in there are blocking Sublime from loading the files that it shipped with. Moving it away (and restarting Sublime) will allow the normal defaults to reassert themselves.

If there is no such folder, then go up one level and look inside of Installed Packages for a file named Default.sublime-package and move that away instead.

In both cases, you’re putting defaults back in place. If the overrides were created by accident (PackageResourceViewer makes it startlingly easy to create overrides when you don’t expect it) then moving the files away is all you need.

On the other hand, if you made the overrides on purpose, then you probably need to re-create them based on the new key bindings.

The OverrideAudit package is designed to detect problems such as this and bring them to your attention, so you may find it useful in the general case (as a disclaimer, I’m the author).

2 Likes

ST4:4113 can't press enter to select file after show files popup
Goto Anything: Enter not working
#3

So I looked in the default keybindings and you were right, that portion is missing.

I then followed what you said and moved the default folder and re-launched sublime. As you said, this new definition for enter now appeared in the default keybindings.

But weirdly, it still didn’t work and I definitely don’t override “enter” in my own keybindings. As a temporary fix, just copying that definition to my custom bindings did the trick which is all I need for now since I’m on a deadline. But I will try to fix this problem permanently later

0 Likes

#4

Thx for the tip.

You don’t know how much grief that simple fix has resolved.

0 Likes

Open reference in active column
#5

The key-binding for the [Enter] key mentioned above is present in the “Default (Linux).sublime-keymap” and is not present in the “Default (Windows).sublime-keymap” and “Default (OSX).sublime-keymap” within the “Default.sublime-package”.
So Windows and MacOS users have to add this key-binding manually unless it is fixed in Sublime Text’s “Default.sublime-package”.

0 Likes

#6

I don’t see any of them being missing in ST4168 on Windows. There are some dups though.

0 Likes

#7

I’m talking about this particular key-binding:

{ "keys": ["enter"], "command": "select", "context":
	[
		{ "key": "overlay_has_focus", "operator": "equal", "operand": true },
		{ "key": "overlay_name", "operator": "equal", "operand" : "goto" }
	],
},

It’s present in “Default (Linux).sublime-keymap” and is not present neither in “Default (OSX).sublime-keymap” nor in “Default (Windows).sublime-keymap”.
This is for Sublime Text Build 4169, Windows version.

0 Likes

#8

But they contain the following more generic ones, which do the same

	// Overlay key bindings
	{ "keys": ["enter"], "command": "select", "context":
		[
			{ "key": "overlay_has_focus", "operator": "equal", "operand": true }
		],
	},
	{ "keys": ["keypad_enter"], "command": "select", "context":
		[
			{ "key": "overlay_has_focus", "operator": "equal", "operand": true }
		],
	},

Windows : Line 840 …850
OSX: 872…880

0 Likes

#9

Probably in my case this more generic binding was conflicting with or was overridden by the following one:

{
	"keys": ["enter"],
	"command": "compass_close",
	"context": [
		{"key": "compass"},
		{"operator": "equal", "operand": true, "key": "overlay_visible"},
		{"operator": "equal", "operand": false, "key": "panel_has_focus"}
	]
},

(This is for Compass Navigator which I use to switch tabs using the keyboard).
So, in my situation I required an explicit rule for the “goto” overlay.

0 Likes