From 580db93eccc9f03cdc31841e294b8c18855013f6 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 8 Jun 2026 03:54:30 +0300 Subject: fix: handle application keypad input refs #493 --- src/raw_input.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/raw_input.rs') diff --git a/src/raw_input.rs b/src/raw_input.rs index a03526d8..8925e4a4 100644 --- a/src/raw_input.rs +++ b/src/raw_input.rs @@ -953,6 +953,7 @@ mod tests { (b"\x1b[127;3u", KeyCode::Backspace, KeyModifiers::ALT), (b"\x1b[57420;1u", KeyCode::Down, KeyModifiers::empty()), (b"\x1b[57423;1u", KeyCode::Home, KeyModifiers::empty()), + (b"\x1bOq", KeyCode::Char('1'), KeyModifiers::empty()), (b"\x1b[49:33;2:1u", KeyCode::Char('1'), KeyModifiers::SHIFT), ]; @@ -963,6 +964,29 @@ mod tests { } } + #[test] + fn raw_framer_waits_for_application_keypad_sequence_final_byte() { + let mut framer = RawInputFramer::default(); + + assert!(framer.push(b"\x1bO").is_empty()); + let events = framer.push(b"q"); + + assert_eq!(events.len(), 1); + assert_raw_key( + events.into_iter().next().unwrap(), + KeyCode::Char('1'), + KeyModifiers::empty(), + ); + } + + #[test] + fn unsupported_ss3_sequence_stays_unsupported() { + let (event, consumed) = extract_one_event(b"\x1bOz").unwrap(); + + assert_eq!(consumed, 3); + assert!(matches!(event, RawInputEvent::Unsupported)); + } + #[test] fn flushes_lone_escape_after_timeout() { let (tx, mut rx) = mpsc::channel(4); -- cgit v1.2.3