diff options
| author | corrius <alvaro.correa@taxdown.es> | 2026-07-24 21:52:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-24 22:52:17 +0300 |
| commit | 38d2b0780c50e4773d6948660873386261cde71d (patch) | |
| tree | b899dd7ce1dfd1a70650be0209a48132c1539a25 /src/app/input/mod.rs | |
| parent | e9b22084e03880f43d1f1daaf5d9f45c717b77c4 (diff) | |
feat: filter keybind help (#1832)
* feat: filter keybind help
refs #1825
* fix: recognize shifted slash in keybind help
---------
Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/app/input/mod.rs')
| -rw-r--r-- | src/app/input/mod.rs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/app/input/mod.rs b/src/app/input/mod.rs index 16713222..f304cde6 100644 --- a/src/app/input/mod.rs +++ b/src/app/input/mod.rs @@ -49,7 +49,8 @@ mod terminal; pub(crate) use self::{ modal::{ handle_global_menu_key, handle_keybind_help_key, handle_navigator_key, - insert_navigator_search_text, insert_rename_input_text, open_new_workspace_dialog, + insert_keybind_help_query_text, insert_navigator_search_text, insert_rename_input_text, + open_new_workspace_dialog, }, navigate::{ terminal_direct_indexed_navigation_action, terminal_direct_non_indexed_navigation_action, @@ -109,7 +110,7 @@ impl App { } Mode::Settings => self.handle_settings_key(key_event), Mode::GlobalMenu => handle_global_menu_key(&mut self.state, key_event), - Mode::KeybindHelp => handle_keybind_help_key(&mut self.state, key_event), + Mode::KeybindHelp => handle_keybind_help_key(&mut self.state, key), Mode::Navigator => { handle_navigator_key(&mut self.state, &self.terminal_runtimes, key_event) } @@ -172,6 +173,13 @@ impl App { insert_navigator_search_text(&mut self.state, &self.terminal_runtimes, text); true } + Mode::KeybindHelp => { + if !self.state.keybind_help.search_focused { + return false; + } + insert_keybind_help_query_text(&mut self.state, text); + true + } Mode::Copy => { let Some(prompt) = self .state @@ -653,6 +661,7 @@ pub(crate) fn modal_paste_target_active(state: &AppState) -> bool { .as_ref() .is_some_and(|open| open.search_focused), Mode::Navigator => state.navigator.search_focused, + Mode::KeybindHelp => state.keybind_help.search_focused, Mode::Copy => state .copy_mode .as_ref() @@ -858,6 +867,21 @@ mod tests { } #[tokio::test] + async fn paste_routes_to_keybind_help_query_only_when_searching() { + let mut app = test_app(); + app.state.mode = Mode::KeybindHelp; + app.handle_paste("ignored".into()).await; + assert!(app.state.keybind_help.query.is_empty()); + + app.state.keybind_help.search_focused = true; + app.state.keybind_help.scroll = 3; + app.handle_paste("work\nspace".into()).await; + + assert_eq!(app.state.keybind_help.query, "workspace"); + assert_eq!(app.state.keybind_help.scroll, 0); + } + + #[tokio::test] async fn paste_routes_to_new_linked_worktree_input() { let mut app = test_app(); app.state.mode = Mode::NewLinkedWorktree; @@ -922,6 +946,12 @@ mod tests { state.navigator.search_focused = true; assert!(modal_paste_target_active(&state)); + state.mode = Mode::KeybindHelp; + state.keybind_help.search_focused = false; + assert!(!modal_paste_target_active(&state)); + state.keybind_help.search_focused = true; + assert!(modal_paste_target_active(&state)); + state.mode = Mode::ConfirmClose; assert!(!modal_paste_target_active(&state)); } |
