Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esc not working when binding #17275

Open
1 task done
gdandersson opened this issue Sep 2, 2024 · 3 comments
Open
1 task done

Esc not working when binding #17275

gdandersson opened this issue Sep 2, 2024 · 3 comments
Labels
keymap / key binding Feedback for keyboard shortcuts, key mapping, etc support User support (non-defect troubleshooting, documentation, etc)

Comments

@gdandersson
Copy link

gdandersson commented Sep 2, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Coming from Textmate, binding escape to completions is a given. But.. binding this in the editor context also makes it impossible to escape/close cmd + t (Search project files..), cmd + shift + p (Execute a command), ctrl + g (Go to line) etc without using the mouse.

I would assume binding escape in the editor didn't affect "popups"/windows, only when editing.

    "bindings": {
      "escape": "editor::ShowCompletions"
    }

Environment

Zed: v0.150.4 (Zed)
OS: macOS 14.5.0
Memory: 32 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log
@gdandersson gdandersson added admin read bug [core label] labels Sep 2, 2024
@notpeter
Copy link
Member

notpeter commented Sep 2, 2024

You've created a global shortcut (no context) you should be able to limit it just to the Editor scope by adding a "context".

  {
    "context": "Editor",
    "bindings": {
      "escape": "editor::ShowCompletions"
    }
  },

See Key Bindings: Context in the docs.

You can look at the source for more examples for examples of the appropriate context for different shortcuts: assets/keymaps/macos/atom.json and assets/keymaps/default-macos.json

@notpeter notpeter closed this as completed Sep 2, 2024
@notpeter notpeter added keymap / key binding Feedback for keyboard shortcuts, key mapping, etc support User support (non-defect troubleshooting, documentation, etc) and removed bug [core label] triage labels Sep 2, 2024
@gdandersson
Copy link
Author

gdandersson commented Sep 2, 2024

That wasn't the full keymap.json. Attaching it here to show that it's within the editor context:

[
	{
		"context": "Workspace",
		"bindings": {
			// "shift shift": "file_finder::Toggle"
		}
	},
	{
		"context": "Editor",
		"bindings": {
			// "j k": ["workspace::SendKeystrokes", "escape"]
			"escape": "editor::ShowCompletions"
		}
	}
]

@notpeter notpeter reopened this Sep 2, 2024
@notpeter
Copy link
Member

notpeter commented Sep 2, 2024

Gotcha. I can reproduce with that keymap. I'm not sure what's the appropriate context for restoring this behavior (none of what I tried worked). For more see:

We have multiple redundant mappings for escape, so as a workaround you could use cmd-esc, ctrl-esc or ctrl-c to cancel those menus:

"escape": "menu::Cancel",
"cmd-escape": "menu::Cancel",
"ctrl-escape": "menu::Cancel",
"ctrl-c": "menu::Cancel",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keymap / key binding Feedback for keyboard shortcuts, key mapping, etc support User support (non-defect troubleshooting, documentation, etc)
Projects
None yet
Development

No branches or pull requests

2 participants