From 0d1f443c26b92fb2217a1aa8a168b932888ef672 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Wed, 14 Feb 2024 13:13:01 +0900 Subject: [PATCH] feat(search): process Ctrl+m for kitty keyboard protocol Fixes https://github.com/atuinsh/atuin/issues/1719 [C-m] is usually identical to [RET] in the terminal protocol, and some users use [C-m] in place of [RET]. However, kitty's extended keyboard protocol enables differentiating them so that [C-m] does not function as does without the extended keyboard protocol. For the compatibility with terminals without extended keyboard protocols, we anyway cannot assign a distinct feature to [C-m], so we can safely add the explicit binding of InputAction::Accept to [C-m]. --- atuin/src/command/client/search/interactive.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/atuin/src/command/client/search/interactive.rs b/atuin/src/command/client/search/interactive.rs index 7680ce5321f..1c71a5b6b4b 100644 --- a/atuin/src/command/client/search/interactive.rs +++ b/atuin/src/command/client/search/interactive.rs @@ -243,6 +243,13 @@ impl State { self.handle_search_scroll_one_line(settings, enable_exit, !settings.invert) } + fn handle_search_accept(&mut self, settings: &Settings) -> InputAction { + if settings.enter_accept { + self.accept = true; + } + InputAction::Accept(self.results_state.selected()) + } + #[allow(clippy::too_many_lines)] #[allow(clippy::cognitive_complexity)] fn handle_search_input(&mut self, settings: &Settings, input: &KeyEvent) -> InputAction { @@ -305,13 +312,8 @@ impl State { } match input.code { - KeyCode::Enter => { - if settings.enter_accept { - self.accept = true; - } - - return InputAction::Accept(self.results_state.selected()); - } + KeyCode::Enter => return self.handle_search_accept(settings), + KeyCode::Char('m') if ctrl => return self.handle_search_accept(settings), KeyCode::Char('y') if ctrl => { return InputAction::Copy(self.results_state.selected()); }