nushell / reedline

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

"Until" keybinding with send empty menu should trigger next action #603

Open Abdillah opened 1 year ago

Abdillah commented 1 year ago

Describe the bug

I tried to stack completion_menu and historynextcomplete in until keybinding.

        until: [
          { send: menu name: completion_menu }
          { send: historyhintwordcomplete }
          { send: menunext }
          { edit: complete }
        ]

Unfortunately, send: menu action doesn't know when the activated menu has no entry. Instead of return as failed, it shows it anyway. In turn, the historynextcomplete doesn't get called that often.

How to reproduce

  1. Modify tab keybinding to look as follow (mainly until stack): ...
    {
      name: completion_menu
      modifier: none
      keycode: tab
      mode: [emacs vi_normal vi_insert]
      event: {
        until: [
          { send: menu name: completion_menu }
          { send: historyhintwordcomplete }
          { send: menunext }
          { edit: complete }
        ]
      }
    }
  2. Type something with possible hint: cd ~
  3. Press tab

Expected behavior

The shell instead choose to complete the hint.

Screenshots

  1. Type something with possible hint Screenshot from 2023-07-15 03-02-04
  2. Press tab Screenshot from 2023-07-15 03-02-10

Configuration

$ version transpose key value to md --pretty key value
version 0.80.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.69.0 (84c898d65 2023-04-16) (built from a source tarball)
cargo_version cargo 1.69.0
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
features default, zip
installed_plugins

Additional context

No response

sholderbach commented 1 year ago

Yeah I don't remember the exact order of possible operations and had to look into reedline's source here https://github.com/nushell/reedline/blob/4f31e200e46b621e96b313ad334d50375fcf624d/src/engine.rs#L855-L886 We only shortcut for directly inserting a single match with the quick_completion mode

sholderbach commented 1 year ago

Moving over to reedline as we need to make the improvements there

Abdillah commented 1 year ago

Hello @sholderbach, I found myself understand the snippet you gave and enough confidence to file a pull request. In my test with my config, the navigation become so much easier.