From 81517eceb129a68b9e86b39fdcfd3da0c2966aed Mon Sep 17 00:00:00 2001 From: Zhanibek Adilbekov Date: Tue, 27 Feb 2024 17:32:15 +0600 Subject: [PATCH] feat: add `CTRL+[` binding as `` alias in Vim/Neovim there is alias for `` mapping -- ``. it is useful if your `` key is hard to hit on your keyboard. for reference: https://vimhelp.org/insert.txt.html#i_CTRL-%5B https://neovim.io/doc/user/insert.html#i_CTRL-%5B --- atuin/src/command/client/search/interactive.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs index bd25cf7b00c..514b42b5348 100644 --- a/atuin/src/command/client/search/interactive.rs +++ b/atuin/src/command/client/search/interactive.rs @@ -189,11 +189,15 @@ impl State { } let ctrl = input.modifiers.contains(KeyModifiers::CONTROL); + let esc_allow_exit = !(self.tab_index == 0 && self.keymap_mode == KeymapMode::VimInsert); // core input handling, common for all tabs match input.code { KeyCode::Char('c' | 'g') if ctrl => return InputAction::ReturnOriginal, - KeyCode::Esc if !(self.tab_index == 0 && self.keymap_mode == KeymapMode::VimInsert) => { + KeyCode::Esc if esc_allow_exit => { + return Self::handle_key_exit(settings); + } + KeyCode::Char('[') if ctrl && esc_allow_exit => { return Self::handle_key_exit(settings); } KeyCode::Tab => { @@ -320,7 +324,7 @@ impl State { _ => {} }, KeymapMode::VimInsert => { - if input.code == KeyCode::Esc { + if input.code == KeyCode::Esc || (ctrl && input.code == KeyCode::Char('[')) { self.set_keymap_cursor(settings, "vim_normal"); self.keymap_mode = KeymapMode::VimNormal; return InputAction::Continue;