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

Remapping keys to close two popups at the same time #5990

Open
xosxos opened this issue Feb 14, 2023 · 3 comments
Open

Remapping keys to close two popups at the same time #5990

xosxos opened this issue Feb 14, 2023 · 3 comments
Labels
A-helix-term Area: Helix term improvements A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements

Comments

@xosxos
Copy link

xosxos commented Feb 14, 2023

Hello, have just switched to helix from neovim and I am quite impressed.

However often when writing, both the code completion and definition pop up appear at the same time. I always use Ctrl-c to close and have remapped C-c = "normal_mode" in all modes. I still find that I need to press it twice to close both popups, but when using Escape, it actually closes both popups and returns to normal mode. Is there a way to remap a key to do whatever Escape does there? I am using the latest 22.12 (0a7cd97d) version built from source.

@the-mikedavis the-mikedavis added C-enhancement Category: Improvements A-helix-term Area: Helix term improvements A-keymap Area: Keymap and keybindings labels Feb 15, 2023
@the-mikedavis
Copy link
Member

the-mikedavis commented Feb 15, 2023

The handling of Escape is a special case in two places:

  • The Popup for signature help uses this flag to ignore Escape so that it passes through to the EditorView layer of the compositor which can consume it to change modes.
  • The Completion component has a special branch for Escape that ignores it for the same effect (see here). (Completion could use ignore_escape_key, I'll make a PR: Use Popup::ignore_escape_key helper for completion #6006)

It's not currently possible to rebind keys for components - that is covered by #5505. Supporting this case might take some extra work on top of that since these two popups are special cases: Escape is not ignored by all Popup components.

@the-mikedavis
Copy link
Member

Building on the pseudocode for the new config in the #5505 description, it might be nice to expose this as the popup's ID tacked onto keys.popup. I'm thinking that this could be supported as:

[keys.popup.completion]
C-c = "ignore"
[keys.popup.signature-help]
C-c = "ignore"

@xosxos
Copy link
Author

xosxos commented Feb 17, 2023

Thank you for the walkthrough! This saved me a lot of time going through the source code. For now, I just forked and use ctrl!(c) as my ignore key. Regarding the config, I instinctively tried this out (it's the mapping I have in all other modes):

[keys.popup]
C-c = "normal_mode"
C-s = ["normal_mode", ":w"]

So I think the proposed config solution in #5505 is very much in line with intuition and using [keys.popup.completion] seems like a natural and flexible continuation of the current system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

2 participants