From 9593e52b47e0dddd39f8bae489eb57dbcf3df790 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Thu, 5 Jun 2025 00:58:17 +0200 Subject: [PATCH 1/2] Use blocking reads for setup_terminal --- src/bin/edit/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/edit/main.rs b/src/bin/edit/main.rs index 71bf1e6a67f..3b52cff8e1e 100644 --- a/src/bin/edit/main.rs +++ b/src/bin/edit/main.rs @@ -15,6 +15,7 @@ use std::borrow::Cow; #[cfg(feature = "debug-latency")] use std::fmt::Write; use std::path::{Path, PathBuf}; +use std::time::Duration; use std::{env, process}; use draw_editor::*; @@ -537,7 +538,11 @@ fn setup_terminal(tui: &mut Tui, state: &mut State, vt_parser: &mut vt::Parser) while !done { let scratch = scratch_arena(None); - let Some(input) = sys::read_stdin(&scratch, vt_parser.read_timeout()) else { + + // We explicitly don't set a read timeout, because we're not + // waiting for user keyboard input. If we encounter a lone ESC, + // it's unlikely to be from a ESC keypress, but rather from a VT sequence. + let Some(input) = sys::read_stdin(&scratch, Duration::MAX) else { break; }; From d3b4320272211fd030bb83bd4bf85810e7f6281d Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Thu, 5 Jun 2025 20:11:16 +0200 Subject: [PATCH 2/2] Set the read timeout to 3s --- src/bin/edit/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/edit/main.rs b/src/bin/edit/main.rs index 3b52cff8e1e..8d683f05116 100644 --- a/src/bin/edit/main.rs +++ b/src/bin/edit/main.rs @@ -539,10 +539,10 @@ fn setup_terminal(tui: &mut Tui, state: &mut State, vt_parser: &mut vt::Parser) while !done { let scratch = scratch_arena(None); - // We explicitly don't set a read timeout, because we're not + // We explicitly set a high read timeout, because we're not // waiting for user keyboard input. If we encounter a lone ESC, // it's unlikely to be from a ESC keypress, but rather from a VT sequence. - let Some(input) = sys::read_stdin(&scratch, Duration::MAX) else { + let Some(input) = sys::read_stdin(&scratch, Duration::from_secs(3)) else { break; };