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

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

Open
Abdillah opened this issue Jul 14, 2023 · 3 comments · May be fixed by #608
Open

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

Abdillah opened this issue Jul 14, 2023 · 3 comments · May be fixed by #608

Comments

@Abdillah
Copy link
Contributor

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

@Abdillah Abdillah changed the title "Until" keybinding with empty menu should trigger next action "Until" keybinding with send empty menu should trigger next action Jul 14, 2023
@sholderbach
Copy link
Member

Yeah I don't remember the exact order of possible operations and had to look into reedline's source here

reedline/src/engine.rs

Lines 855 to 886 in 4f31e20

ReedlineEvent::Menu(name) => {
if self.active_menu().is_none() {
if let Some(menu) = self.menus.iter_mut().find(|menu| menu.name() == name) {
menu.menu_event(MenuEvent::Activate(self.quick_completions));
if self.quick_completions && menu.can_quick_complete() {
menu.update_values(
&mut self.editor,
self.completer.as_mut(),
self.history.as_ref(),
);
if menu.get_values().len() == 1 {
return self.handle_editor_event(prompt, ReedlineEvent::Enter);
}
}
if self.partial_completions
&& menu.can_partially_complete(
self.quick_completions,
&mut self.editor,
self.completer.as_mut(),
self.history.as_ref(),
)
{
return Ok(EventStatus::Handled);
}
return Ok(EventStatus::Handled);
}
}
Ok(EventStatus::Inapplicable)
We only shortcut for directly inserting a single match with the quick_completion mode

@sholderbach
Copy link
Member

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

@sholderbach sholderbach transferred this issue from nushell/nushell Jul 14, 2023
@Abdillah
Copy link
Contributor Author

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.

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

Successfully merging a pull request may close this issue.

2 participants