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

ignore Enter keypress when menu has no selection #1704

Conversation

the-mikedavis
Copy link
Member

supersedes #1622

Uses the new EventResult member introduced 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):

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.

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.
helix-term/src/ui/menu.rs Outdated Show resolved Hide resolved
helix-term/src/ui/menu.rs Outdated Show resolved Hide resolved
@the-mikedavis the-mikedavis force-pushed the md-ignore-enter-event-in-menu-on-no-selection branch from 03112b4 to 038aaa1 Compare February 25, 2022 18:09
@the-mikedavis
Copy link
Member Author

I ran into some type and life-cycle stuff I don't really understand yet. I'll do some reading and swing back around to this PR when I understand more 👍

helix-term/src/ui/menu.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants