From 6f9ca0ea6648778419ba18c882eefba4615f3f43 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 16 Jun 2026 15:19:06 +0300 Subject: fix: hold lone escape while awaiting host color reply refs #549 --- src/client/input.rs | 22 ++++++++++++++++++---- src/client/mod.rs | 6 ++++-- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src/client') diff --git a/src/client/input.rs b/src/client/input.rs index b89a57b1..a17c2404 100644 --- a/src/client/input.rs +++ b/src/client/input.rs @@ -32,20 +32,34 @@ use super::ClientLoopEvent; /// This runs on a dedicated thread because stdin reading is blocking. /// The main loop receives the raw bytes and forwards them as /// `ClientMessage::Input` to the server. -pub fn stdin_reader_loop(event_tx: mpsc::Sender, should_quit: &Arc) { +pub fn stdin_reader_loop( + event_tx: mpsc::Sender, + should_quit: &Arc, + host_color_query_sent: bool, +) { #[cfg(windows)] - return windows_stdin_reader_loop(event_tx, should_quit); + { + let _ = host_color_query_sent; + return windows_stdin_reader_loop(event_tx, should_quit); + } #[cfg(unix)] - unix_stdin_reader_loop(event_tx, should_quit); + unix_stdin_reader_loop(event_tx, should_quit, host_color_query_sent); } #[cfg(unix)] -fn unix_stdin_reader_loop(event_tx: mpsc::Sender, should_quit: &Arc) { +fn unix_stdin_reader_loop( + event_tx: mpsc::Sender, + should_quit: &Arc, + host_color_query_sent: bool, +) { let stdin = io::stdin(); let mut reader = stdin.lock(); let mut scratch = [0u8; 4096]; let mut framer = crate::raw_input::RawInputByteFramer::default(); + if host_color_query_sent { + framer.host_color_query_sent(); + } while !should_quit.load(Ordering::Acquire) { match reader.read(&mut scratch) { diff --git a/src/client/mod.rs b/src/client/mod.rs index b7fd212d..2fc899ce 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -778,13 +778,15 @@ async fn run_client_loop( let (event_tx, mut event_rx) = tokio::sync::mpsc::channel::(256); // Spawn the stdin reader thread. + let will_query_host_terminal_theme = + state.attach_escape.is_none() && should_query_host_terminal_theme(); let stdin_quit = should_quit.clone(); let stdin_tx = event_tx.clone(); std::thread::spawn(move || { - input::stdin_reader_loop(stdin_tx, &stdin_quit); + input::stdin_reader_loop(stdin_tx, &stdin_quit, will_query_host_terminal_theme); }); - if state.attach_escape.is_none() && should_query_host_terminal_theme() { + if will_query_host_terminal_theme { query_host_terminal_theme(); } -- cgit v1.2.3