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

Event for accepting a menu item #624

Open
chtenb opened this issue Apr 14, 2022 · 3 comments
Open

Event for accepting a menu item #624

chtenb opened this issue Apr 14, 2022 · 3 comments

Comments

@chtenb
Copy link

chtenb commented Apr 14, 2022

Related problem

I would like to change the keyboard binding for accepting a completion command. Currently this is "enter", but it would be nice if we could make this some other key. For executing the command I would like the key to remain "enter".

The reason I like to change this is to make my completion experience more uniform across different tools .

Describe the solution you'd like

Judging from the keybindings list command, there is not a MenuAccept event to be leveraged. Would it make sense to add such an event?

Describe alternatives you've considered

There is already a command named "Enter", but this seems to cover both accepting a suggestion and executing the command.
I tried for instance

    {
      name: accept_suggestion
      name: commands_menu
      modifier: none
      keycode: tab
      mode: emacs
      event: { 
        until: [ 
          { send: HistoryHintWordComplete } 
          { send: Enter } 
        ]
      }
    }

but this remaps the execute command key as well, which is not what I want.

Additional context and details

No response

@sholderbach
Copy link
Member

Would Tab be the key you want to map it to? Would having accepting on Enter as well still be fine? (The until command system makes the state machine kind of messy for each of those) Or do you want to basically have the completions fill in the buffer while selecting, so that you can just continue typing?

@chtenb
Copy link
Author

chtenb commented Apr 14, 2022

Would Tab be the key you want to map it to?

Yes, that was my idea. Or more specifically, I want my tab key to accept the selected menu selection, or if no menu was active apply history completion. The latter already works.

Would having accepting on Enter as well still be fine?

I'm not sure. I guess it's fine, but for me the enter key is really about executing the command. So if I browsed some menu suggestions but decide I don't want any of them I'd like to be able to execute the command, in theory. I'm not sure how often this scenario happens in practice though, but that would be ideal I think.

Or do you want to basically have the completions fill in the buffer while selecting, so that you can just continue typing?

That also sounds decent to me, but I'm not sure if you could "unselect" the completion menu once you browsed through the completion options, in case you don't want any of the suggestions? Currently that doesn't seem possible with the completion menu. Another concern is that it doesn't quite match up with other tools I'm using, and not all tools provide the flexibility to behave like this.

I think in principle both behaviors are fine, but depending on what other tools someone is using they may have a preference for one or the other. So in general we may want to support both options?

@sophiajt
Copy link
Contributor

I believe this is still valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants