nushell / reedline

A feature-rich line editor - powering Nushell
https://docs.rs/reedline/
MIT License
551 stars 155 forks source link

New actions to cancel menu & accept-and-hold #767

Open bew opened 8 months ago

bew commented 8 months ago

Hello o/

When using the vi mode, when the completion menu is open, there is no way to cancel/hide the menu while staying in insert mode (pressing escape will hide the menu but also go to normal mode which I ~never want). 👉 I'd like to have a MenuCancel action to cancel the menu without changing the current mode.

Related to that, if I type echo f in a directory with files foobar & foobaz, the input will be changed to foo (the longest common text of the completion candidates), then when pressing escape to try to cancel the menu, the original input is not restored (I am left with echo foo instead of echo f. I don't know if this should be filed as a bug report, but MenuCancel should restore the original input 🙏

video showing this behavior(/bug?) https://github.com/nushell/reedline/assets/9730330/00709df8-2041-4439-85a1-e5b3fc2606af

Another menu action I'd I'm found of in zsh is the ability to accept current completion but keep the exact same completion menu open (and moving the selected completion to the next). 👉 I'd like to have MenuAcceptAndHold to accept current selection, append a space + what was used for previous completion and continue showing the completion menu. Selecting the next entry could be moved avoided if we can execute multiple actions in a keybinding 🤔 (note: related to #624 asking for something like a MenuAccept action)

video showing this behavior in zsh https://github.com/nushell/reedline/assets/9730330/af4902ed-ab2f-423c-b202-8a7e8fd6fff2

References

Zsh Line Editor (ZLE) has bindable actions do that: