From 3825c0c30099dbe4cf19627b0525ce09f6580995 Mon Sep 17 00:00:00 2001 From: akbash Date: Thu, 6 Aug 2026 17:38:20 +0300 Subject: fix(theme): refresh host appearance on focus (#2417) * fix(theme): refresh host appearance on focus refs #2416 * fix(input): preserve split appearance replies refs #2416 * fix(input): retain fragmented appearance reports refs #2416 --------- Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik --- src/client/input.rs | 1 + src/client/mod.rs | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'src/client') diff --git a/src/client/input.rs b/src/client/input.rs index 9e0d300e..4dc26eae 100644 --- a/src/client/input.rs +++ b/src/client/input.rs @@ -77,6 +77,7 @@ fn unix_stdin_reader_loop( if host_color_query_sent { framer.host_color_query_sent(); framer.enable_host_color_scheme_change_tracking(); + framer.enable_host_appearance_query_on_focus(); } if host_cell_size_query_sent { framer.host_cell_size_query_sent(); diff --git a/src/client/mod.rs b/src/client/mod.rs index fd92d188..b153dd93 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -1442,6 +1442,9 @@ async fn run_client_loop( ) { state.request_repaint(); } + if crate::raw_input::events_require_host_terminal_appearance_query(&events) { + query_host_terminal_appearance(); + } if crate::raw_input::events_require_host_terminal_theme_query(&events) { query_host_terminal_theme(); } @@ -2281,6 +2284,17 @@ fn resize_poll_loop( // Logging // --------------------------------------------------------------------------- +#[cfg(any(not(windows), test))] +fn query_host_terminal_appearance() { + let _ = write_host_terminal_appearance_query(io::stdout()); +} + +#[cfg(any(not(windows), test))] +fn write_host_terminal_appearance_query(mut writer: impl io::Write) -> io::Result<()> { + writer.write_all(crate::terminal_theme::HOST_COLOR_SCHEME_QUERY_SEQUENCE.as_bytes())?; + writer.flush() +} + /// Initialize logging for the client process. fn query_host_terminal_theme() { let _ = write_host_terminal_theme_query(io::stdout()); @@ -2672,6 +2686,13 @@ mod tests { assert!(!text.contains("d=A")); } + #[test] + fn write_host_terminal_appearance_query_emits_mode_2031_query() { + let mut output = Vec::new(); + write_host_terminal_appearance_query(&mut output).unwrap(); + assert_eq!(output, b"\x1b[?996n"); + } + #[test] fn write_host_terminal_theme_query_emits_osc_queries() { let mut output = Vec::new(); @@ -2680,6 +2701,10 @@ mod tests { output, crate::terminal_theme::host_terminal_theme_query_sequence().as_bytes() ); + assert!(!output + .windows(crate::terminal_theme::HOST_COLOR_SCHEME_QUERY_SEQUENCE.len()) + .any(|window| window + == crate::terminal_theme::HOST_COLOR_SCHEME_QUERY_SEQUENCE.as_bytes())); } #[test] -- cgit v1.2.3