Protect some cursor movements against untimely ctrl-c

Commit 01dbfb0a3f (replace writestr() with fwprintf() in reader.cpp,
2016-12-20) accidentally replaced a retry-on-EINTR write with a
non-retrying version. Commit 7f31acbf9b (Prevent fish_title output
from triggering a bel, 2022-02-02) fixed this for some cases but
not all, fix that.
This commit is contained in:
Johannes Altmanninger 2024-12-29 14:36:11 +01:00
parent 376bf3a982
commit 41e82c8c9e

View file

@ -130,7 +130,7 @@ use crate::wcstringutil::{
string_prefixes_string_case_insensitive, StringFuzzyMatch,
};
use crate::wildcard::wildcard_has;
use crate::wutil::{fstat, perror, write_to_fd};
use crate::wutil::{fstat, perror};
use crate::{abbrs, event, function, history};
/// A description of where fish is in the process of exiting.
@ -1979,7 +1979,7 @@ impl<'a> Reader<'a> {
// HACK: If stdin isn't the same terminal as stdout, we just moved the cursor.
// For now, just reset it to the beginning of the line.
if zelf.conf.inputfd != STDIN_FILENO {
let _ = write_to_fd(b"\r", STDOUT_FILENO);
let _ = write_loop(&STDOUT_FILENO, b"\r");
}
// Ensure we have no pager contents when we exit.
@ -4142,7 +4142,7 @@ pub fn reader_write_title(
.set_color(RgbColor::RESET, RgbColor::RESET);
if reset_cursor_position && !lst.is_empty() {
// Put the cursor back at the beginning of the line (issue #2453).
let _ = write_to_fd(b"\r", STDOUT_FILENO);
let _ = write_loop(&STDOUT_FILENO, b"\r");
}
}