From 19cd372f2544f56af9be1f24a67cb229e82bb63d Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sun, 26 Jul 2026 14:43:48 +0300 Subject: [PATCH] fix: preserve prefix mode for modifier events refs #1870 --- src/app/input/navigate.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs index 6b578091..4cb2a4e1 100644 --- a/src/app/input/navigate.rs +++ b/src/app/input/navigate.rs @@ -61,6 +61,10 @@ impl App { let key = raw_key.as_key_event(); self.state.update_dismissed = true; + if matches!(key.code, KeyCode::Modifier(_)) { + return; + } + if self.state.is_prefix_key(raw_key) { if self.state.copy_mode_pane_is_focused() { self.state.cancel_copy_mode(&self.terminal_runtimes); @@ -1867,7 +1871,7 @@ mod tests { #[cfg(unix)] use std::time::Duration; - use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; + use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, ModifierKeyCode}; use ratatui::layout::Direction; #[cfg(unix)] @@ -2621,6 +2625,30 @@ last_pane = "prefix+tab" } } + #[test] + fn prefix_shift_indexed_workspace_shortcut_survives_modifier_press() { + let mut app = app_with_test_workspaces(&["one", "two"]); + let config: Config = + toml::from_str("[keys]\nswitch_workspace = \"prefix+shift+1..9\"\n").unwrap(); + app.state.keybinds.switch_workspace = config.keybinds().switch_workspace; + app.state.mode = Mode::Prefix; + + app.handle_prefix_key(TerminalKey::new( + KeyCode::Modifier(ModifierKeyCode::LeftShift), + KeyModifiers::SHIFT, + )); + + assert_eq!(app.state.mode, Mode::Prefix); + + app.handle_prefix_key( + TerminalKey::new(KeyCode::Char('2'), KeyModifiers::SHIFT) + .with_shifted_codepoint('"' as u32), + ); + + assert_eq!(app.state.active, Some(1)); + assert_eq!(app.state.mode, Mode::Terminal); + } + #[test] fn prefix_unshifted_indexed_shortcut_maps_shifted_french_number_row() { let mut state = state_with_workspaces(&["one"]);