From d18f34daa47a9932a2b45551c83ac5efc8c4eb86 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Sun, 10 Apr 2022 22:48:55 +0200 Subject: [PATCH] Allow overriding of menu keybindings (#5148) Keybindings that were attached to menus like `Ctrl-x` or `Ctrl-q` could not be replaced with custom bindings --- crates/nu-cli/src/reedline_config.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/nu-cli/src/reedline_config.rs b/crates/nu-cli/src/reedline_config.rs index 7723341ef..ef04966cb 100644 --- a/crates/nu-cli/src/reedline_config.rs +++ b/crates/nu-cli/src/reedline_config.rs @@ -543,6 +543,15 @@ pub(crate) fn create_keybindings(config: &Config) -> Result { + add_menu_keybindings(&mut emacs_keybindings); + } + _ => { + add_menu_keybindings(&mut insert_keybindings); + add_menu_keybindings(&mut normal_keybindings); + } + } for keybinding in parsed_keybindings { add_keybinding( &keybinding.mode, @@ -555,20 +564,11 @@ pub(crate) fn create_keybindings(config: &Config) -> Result { - add_menu_keybindings(&mut emacs_keybindings); - - Ok(KeybindingsMode::Emacs(emacs_keybindings)) - } - _ => { - add_menu_keybindings(&mut insert_keybindings); - add_menu_keybindings(&mut normal_keybindings); - - Ok(KeybindingsMode::Vi { - insert_keybindings, - normal_keybindings, - }) - } + "emacs" => Ok(KeybindingsMode::Emacs(emacs_keybindings)), + _ => Ok(KeybindingsMode::Vi { + insert_keybindings, + normal_keybindings, + }), } }