diff --git a/src/reader.cpp b/src/reader.cpp index 929295deb..028cefced 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1438,6 +1438,9 @@ static void reader_flash() { reader_repaint(); ignore_result(write(STDOUT_FILENO, "\a", 1)); + // The write above changed the timestamp of stdout; ensure we don't therefore reset our screen. + // See #3693. + s_save_status(&data->screen); pollint.tv_sec = 0; pollint.tv_nsec = 100 * 1000000; diff --git a/src/screen.cpp b/src/screen.cpp index 3750ac818..817468ac2 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -352,7 +352,7 @@ static size_t calc_prompt_lines(const wcstring &prompt) { /// Stat stdout and stderr and save result. This should be done before calling a function that may /// cause output. -static void s_save_status(screen_t *s) { +void s_save_status(screen_t *s) { fstat(1, &s->prev_buff_1); fstat(2, &s->prev_buff_2); } diff --git a/src/screen.h b/src/screen.h index 146f60a78..2bb201a2d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -181,6 +181,9 @@ void s_write(screen_t *s, const wcstring &left_prompt, const wcstring &right_pro /// line of garbage for every repaint, which will quickly fill the screen. void s_reset(screen_t *s, bool reset_cursor, bool reset_prompt = true); +/// Stat stdout and stderr and save result as the current timestamp. +void s_save_status(screen_t *s); + enum screen_reset_mode_t { /// Do not make a new line, do not repaint the prompt. screen_reset_current_line_contents,