diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-18 02:51:29 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-18 02:51:29 +0300 |
| commit | c1f7b6f331501a784bfad896310eae1d064bd9b9 (patch) | |
| tree | bcab5fd693c024543ab90ea766f56153c4fee891 /src/client | |
| parent | e298e4589050349630d0faaec00ef11555b83ae1 (diff) | |
fix: preserve lone escape input boundaries
refs #541
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/input.rs | 28 | ||||
| -rw-r--r-- | src/client/input/windows_vti.rs | 10 |
2 files changed, 27 insertions, 11 deletions
diff --git a/src/client/input.rs b/src/client/input.rs index a49c4316..1d557543 100644 --- a/src/client/input.rs +++ b/src/client/input.rs @@ -66,7 +66,7 @@ fn unix_stdin_reader_loop( let stdin = io::stdin(); let mut reader = stdin.lock(); let mut scratch = [0u8; 4096]; - let mut framer = crate::raw_input::RawInputByteFramer::default(); + let mut framer = crate::raw_input::RawInputByteFramer::for_host_input(); if host_color_query_sent { framer.host_color_query_sent(); framer.enable_host_color_scheme_change_tracking(); @@ -164,19 +164,17 @@ fn windows_crossterm_reader_loop( event_tx: mpsc::Sender<ClientLoopEvent>, should_quit: &Arc<AtomicBool>, ) { - let mut framer = crate::raw_input::RawInputFramer::default(); - let mut raw_sequence_pending = false; + let mut framer = crate::raw_input::RawInputFramer::for_host_input(); while !should_quit.load(Ordering::Acquire) { match crossterm::event::poll(Duration::from_millis(10)) { Ok(true) => {} Ok(false) => { - if raw_sequence_pending { + if framer.has_pending_input() { tracing::debug!("windows input raw sequence timed out; flushing"); if !send_windows_raw_events(framer.flush_timeout(), &event_tx) { return; } - raw_sequence_pending = false; } continue; } @@ -188,15 +186,14 @@ fn windows_crossterm_reader_loop( Err(_) => break, }; + let raw_sequence_pending = framer.has_pending_input(); if let Some(bytes) = windows_key_raw_bytes(&event, raw_sequence_pending) { tracing::debug!( bytes = ?bytes, pending_before = raw_sequence_pending, "windows input routed through raw framer" ); - let events = framer.push(&bytes); - raw_sequence_pending = events.is_empty(); - if !send_windows_raw_events(events, &event_tx) { + if !send_windows_raw_events(framer.push(&bytes), &event_tx) { return; } continue; @@ -207,7 +204,6 @@ fn windows_crossterm_reader_loop( if !send_windows_raw_events(framer.flush_timeout(), &event_tx) { return; } - raw_sequence_pending = false; } if windows_event_is_control_key(&event) { @@ -225,7 +221,7 @@ fn windows_crossterm_reader_loop( } } - if raw_sequence_pending { + if framer.has_pending_input() { let _ = send_windows_raw_events(framer.flush_timeout(), &event_tx); } } @@ -403,6 +399,18 @@ mod tests { assert!(timeout_ms <= 20); } + #[cfg(not(target_os = "macos"))] + #[test] + fn windows_repeated_escape_keeps_second_escape_pending() { + let mut framer = crate::raw_input::RawInputFramer::for_host_input(); + + let events = framer.push(b"\x1b\x1b"); + + assert_eq!(events.len(), 1); + assert!(framer.has_pending_input()); + assert_eq!(framer.flush_timeout().len(), 1); + } + #[test] fn mouse_active_escape_sequences_get_longer_reassembly_window() { let mut escape = crate::raw_input::RawInputByteFramer::default(); diff --git a/src/client/input/windows_vti.rs b/src/client/input/windows_vti.rs index 6404e586..3b29e790 100644 --- a/src/client/input/windows_vti.rs +++ b/src/client/input/windows_vti.rs @@ -191,12 +191,20 @@ struct WindowsInputMapper { win32_input: WindowsWin32InputModeFramer, } -#[derive(Default)] struct WindowsInputPump { framer: crate::raw_input::RawInputFramer, paste_from_win32_key_records: bool, } +impl Default for WindowsInputPump { + fn default() -> Self { + Self { + framer: crate::raw_input::RawInputFramer::for_host_input(), + paste_from_win32_key_records: false, + } + } +} + #[derive(Clone, Debug, PartialEq, Eq)] enum PlatformInputItem { Bytes(Vec<u8>), |
