diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-09 05:10:35 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-09 05:10:35 +0300 |
| commit | d277d2f83b749a38c90eb96ef7cd329cc2171cd7 (patch) | |
| tree | ec4b516401fc97d8356b85557e407c1d216aa24b /src/input/parse.rs | |
| parent | 2baebb50b0a2c639fb7fc1a4488994c78d4a0b89 (diff) | |
fix(input): preserve alt-prefixed control keys (#2543)
refs #2514
Diffstat (limited to 'src/input/parse.rs')
| -rw-r--r-- | src/input/parse.rs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/input/parse.rs b/src/input/parse.rs index 085757c3..b2318339 100644 --- a/src/input/parse.rs +++ b/src/input/parse.rs @@ -87,12 +87,9 @@ fn parse_legacy_key_sequence(data: &str) -> Option<TerminalKey> { _ if data.starts_with('\x1b') => { let rest = data.strip_prefix('\x1b')?; if rest.chars().count() == 1 { - let ch = rest.chars().next()?; - let mut modifiers = KeyModifiers::ALT; - if ch.is_ascii_uppercase() { - modifiers |= KeyModifiers::SHIFT; - } - Some(TerminalKey::new(KeyCode::Char(ch), modifiers)) + let mut key = parse_legacy_key_sequence(rest)?; + key.modifiers |= KeyModifiers::ALT; + Some(key) } else { None } @@ -550,6 +547,23 @@ mod tests { } #[test] + fn parse_legacy_alt_control_letter_composes_modifiers() { + let key = parse_terminal_key_sequence("\x1b\x06") + .expect("ctrl-alt-f legacy sequence should parse"); + assert_terminal_key_eq( + key.clone(), + KeyCode::Char('f'), + KeyModifiers::CONTROL | KeyModifiers::ALT, + crossterm::event::KeyEventKind::Press, + None, + ); + assert_eq!( + encode_terminal_key(key, KeyboardProtocol::Legacy), + b"\x1b\x06" + ); + } + + #[test] fn unknown_legacy_ss3_sequence_remains_unsupported() { assert!(parse_terminal_key_sequence("\x1bOz").is_none()); } |
