From 4a8a8f9087cc2576ad643858d7483de46268f449 Mon Sep 17 00:00:00 2001 From: PISIT KOOLPLUKPOL Date: Tue, 11 Aug 2026 03:02:21 +0700 Subject: fix(input): ignore modified j/k/up/down in session navigator (#2377) The Char('j')/Char('k')/Down/Up match arms in handle_navigator_key had no modifier guard, unlike every sibling arm in the same match block, so Ctrl+K, Alt+J, etc. also moved the navigator selection. refs #1981 Co-authored-by: Can Celik --- src/app/input/modal.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/app') diff --git a/src/app/input/modal.rs b/src/app/input/modal.rs index 7a9ffe46..343fa99c 100644 --- a/src/app/input/modal.rs +++ b/src/app/input/modal.rs @@ -241,10 +241,10 @@ pub(crate) fn handle_navigator_key( state.navigator.state_filter = Some(NavigatorStateFilter::Done); state.select_first_navigator_match_from(terminal_runtimes); } - KeyCode::Char('j') | KeyCode::Down => { + KeyCode::Char('j') | KeyCode::Down if key.modifiers.is_empty() => { state.move_navigator_selection_from(terminal_runtimes, 1) } - KeyCode::Char('k') | KeyCode::Up => { + KeyCode::Char('k') | KeyCode::Up if key.modifiers.is_empty() => { state.move_navigator_selection_from(terminal_runtimes, -1) } KeyCode::Char('d') if key.modifiers == KeyModifiers::CONTROL => state @@ -2002,6 +2002,30 @@ mod tests { assert_eq!(state.mode, Mode::Terminal); } + #[test] + fn navigator_ignores_modified_j_and_k() { + let mut state = state_with_workspaces(&["alpha", "beta"]); + let terminal_runtimes = crate::terminal::TerminalRuntimeRegistry::new(); + state.mode = Mode::Navigator; + state.navigator.selected = 1; + + handle_navigator_key( + &mut state, + &terminal_runtimes, + KeyEvent::new(KeyCode::Char('k'), KeyModifiers::CONTROL), + ); + + assert_eq!(state.navigator.selected, 1); + + handle_navigator_key( + &mut state, + &terminal_runtimes, + KeyEvent::new(KeyCode::Char('j'), KeyModifiers::CONTROL), + ); + + assert_eq!(state.navigator.selected, 1); + } + #[test] fn open_rename_active_tab_can_prefill_default_new_tab_name() { let mut state = state_with_workspaces(&["test"]); -- cgit v1.2.3