From 25f070919cee3dd2dbce386399500146ea2fa208 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Sat, 9 May 2026 14:43:58 -0500 Subject: [PATCH] test(tui): gate ANSI-byte recover_terminal_modes asserts to non-windows Crossterm routes the same logical commands through the WinAPI console backend on Windows, so EnableFocusChange / Push keyboard flags / EnableMouseCapture / EnableBracketedPaste never reach the writer as ANSI bytes there. Gate the byte-level test with cfg(not(windows)) and add a windows-only smoke test that just exercises the function for panic-freedom. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/tui/src/tui/ui/tests.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/tui/src/tui/ui/tests.rs b/crates/tui/src/tui/ui/tests.rs index 91ecc5c2..6cc06f19 100644 --- a/crates/tui/src/tui/ui/tests.rs +++ b/crates/tui/src/tui/ui/tests.rs @@ -36,6 +36,11 @@ fn focus_gained_forces_terminal_viewport_recapture() { assert!(!terminal_event_needs_viewport_recapture(&Event::FocusLost)); } +// ANSI byte sequences are only written on platforms where crossterm uses the +// ANSI execution path. On Windows the same logical commands route through the +// WinAPI console backend and never reach the writer, so byte-level assertions +// here only make sense on non-Windows targets. +#[cfg(not(windows))] #[test] fn recover_terminal_modes_emits_expected_csi_sequences_with_gating() { let mut all_on: Vec = Vec::new(); @@ -73,6 +78,14 @@ fn recover_terminal_modes_emits_expected_csi_sequences_with_gating() { ); } +#[cfg(windows)] +#[test] +fn recover_terminal_modes_runs_without_panic_on_windows() { + let mut buf: Vec = Vec::new(); + recover_terminal_modes(&mut buf, true, true); + recover_terminal_modes(&mut buf, false, false); +} + #[test] fn terminal_origin_reset_resets_scroll_region_origin_and_clears() { assert!(