-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
remove Enter keybinding from menu picker #1622
remove Enter keybinding from menu picker #1622
Conversation
I'm assuming you have completion delay set to 0? If I remember correctly, we can now both ignore the event and trigger a callback so what I'd do is: if an option is selected, trigger it and close the menu, or if no option is selected, close the menu and trigger a newline. |
Might need changes from #1285 though, which adds that "ignore + callback" return |
How will this interact with additional text changes like auto-imports ? IIRC it's triggered on Enter. |
I need to double check but I think I addressed that with the "snapshot" feature and it's now always applied and reverted |
Yep, I forgot about that setting, I should probably try with something very small, I bet that'd fix it most of the time. And #1285 and |
supersedes helix-editor#1622 Builds on the work in helix-editor#1285. I want to allow Enter to create a newline when there is no selection in the autocomplete menu. This occurs somewhat often when using LSP autocomplete in Elixir which uses `do/end` blocks (and I set the autocomplete menu delay to 0 which exacerbates the problem): ```elixir defmodule MyModule do def do_foo(x) do x end def other_function(y) do| end ``` Here the cursor is `|` in insert mode. The LSP suggests `do_foo` but I want to create a newline. Hitting Enter currently closes the menu, so I end up having to hit Enter twice when the module contains any local with a `do` prefix, which can be inconsistent. With this change, we ignore the Enter keypress to end up creating the newline in this case.
* ignore Enter keypress when menu has no selection supersedes #1622 Builds on the work in #1285. I want to allow Enter to create a newline when there is no selection in the autocomplete menu. This occurs somewhat often when using LSP autocomplete in Elixir which uses `do/end` blocks (and I set the autocomplete menu delay to 0 which exacerbates the problem): ```elixir defmodule MyModule do def do_foo(x) do x end def other_function(y) do| end ``` Here the cursor is `|` in insert mode. The LSP suggests `do_foo` but I want to create a newline. Hitting Enter currently closes the menu, so I end up having to hit Enter twice when the module contains any local with a `do` prefix, which can be inconsistent. With this change, we ignore the Enter keypress to end up creating the newline in this case. * pop compositor layer when ignoring Enter keypress * move closing function out of consumed event result closure * explicitly label close_fn as an 'Option<Callback>'
I've been running with this commit in my build for a bit, it fixes a wonky scenario where I want Enter to create a newline but instead it only closes the completion menu. It happens very often in Elixir because of
do/end
blocks:(Where I'm in insert mode after typing that 'do' next to the cursor '|'). The LSP will bring up the menu to suggest
do_foo/1
, so when I hit Enter to start a new line, the completion menu is closed but the newline isn't inserted.I think this change also makes sense because