From fedd879b2e76f4d096a7b3ba89cfa4d0ee818bdb Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:19:39 +0200 Subject: [PATCH] support tab completion cycling (#10199) should close https://github.com/nushell/nushell/issues/7202 # Description i have been annoyed enough by this missing feature, so let's add that to Nushell without requiring any user configuration :smirk: # User-Facing Changes this PR should allow tab completion cycling everytime, without requiring the user to use the default config files or add the following keybindings to their config ```nushell { name: completion_menu modifier: none keycode: tab mode: [emacs vi_normal vi_insert] event: { until: [ { send: menu name: completion_menu } { send: menunext } { edit: complete } ] } } ``` ### :test_tube: try it out from the root of the repo, one can try `` in each of the following cases: - `cargo run -- -n` to load Nushell without any config - `cargo run -- --config crates/nu-utils/src/sample_config/default_config.nu --env-config crates/nu-utils/src/sample_config/default_env.nu` to load the default configuration - `cargo run` to load the user configuration ## before - ``, `ls ` and `str ` only work with the second `cargo run`, i.e. when loading the default config files ## after - `` should cycle through the available commands - `ls ` should cycle through the available files and directories - `str ` should cycle the subcommands of `str` in all three cases # Tests + Formatting # After submitting --- crates/nu-cli/src/reedline_config.rs | 1 + crates/nu-utils/src/sample_config/default_config.nu | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/nu-cli/src/reedline_config.rs b/crates/nu-cli/src/reedline_config.rs index 2453734d4d..5be1f77975 100644 --- a/crates/nu-cli/src/reedline_config.rs +++ b/crates/nu-cli/src/reedline_config.rs @@ -476,6 +476,7 @@ fn add_menu_keybindings(keybindings: &mut Keybindings) { KeyCode::Tab, ReedlineEvent::UntilFound(vec![ ReedlineEvent::Menu("completion_menu".to_string()), + ReedlineEvent::MenuNext, ReedlineEvent::Edit(vec![EditCommand::Complete]), ]), ); diff --git a/crates/nu-utils/src/sample_config/default_config.nu b/crates/nu-utils/src/sample_config/default_config.nu index 6dd9c54d66..b395b9ae0e 100644 --- a/crates/nu-utils/src/sample_config/default_config.nu +++ b/crates/nu-utils/src/sample_config/default_config.nu @@ -320,6 +320,7 @@ $env.config = { until: [ { send: menu name: completion_menu } { send: menunext } + { edit: complete } ] } }