mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 23:11:14 -03:00
Use Write::write_all(), not write()
There is no guarantee that Write::write() will write the entirety of the provided buffer in one go, regardless of how short it is, because that depends on the semantics of the underlying write handle (even if it was a single byte, though in this case that would be because of an interrupt). The only case I'm aware of that would guarantee a single Write::write() call would suffice is when writing into a high-level memory-backed buffer, and we can't make that guarantee (now or in perpetuity).
This commit is contained in:
@@ -432,7 +432,7 @@ pub fn tputs(&mut self, str: &CStr) {
|
||||
|
||||
pub fn tputs_bytes(&mut self, str: &[u8]) {
|
||||
self.begin_buffering();
|
||||
let _ = self.write(str);
|
||||
let _ = self.write_all(str);
|
||||
self.end_buffering();
|
||||
}
|
||||
|
||||
|
||||
@@ -1416,7 +1416,7 @@ pub fn request_cursor_position(
|
||||
assert!(self.blocking_wait.is_none());
|
||||
self.blocking_wait = Some(BlockingWait::CursorPosition(cursor_position_wait));
|
||||
}
|
||||
let _ = out.write(b"\x1b[6n");
|
||||
let _ = out.write_all(b"\x1b[6n");
|
||||
self.save_screen_state();
|
||||
}
|
||||
|
||||
@@ -2175,12 +2175,12 @@ fn readline(&mut self, nchars: Option<NonZeroUsize>) -> Option<WString> {
|
||||
let mut out = Outputter::stdoutput().borrow_mut();
|
||||
out.begin_buffering();
|
||||
// Query for kitty keyboard protocol support.
|
||||
let _ = out.write(kitty_progressive_enhancements_query());
|
||||
let _ = out.write_all(kitty_progressive_enhancements_query());
|
||||
// Query for cursor position reporting support.
|
||||
zelf.request_cursor_position(&mut out, None);
|
||||
// Query for synchronized output support.
|
||||
let _ = out.write(b"\x1b[?2026$p");
|
||||
let _ = out.write(QUERY_PRIMARY_DEVICE_ATTRIBUTE);
|
||||
let _ = out.write_all(b"\x1b[?2026$p");
|
||||
let _ = out.write_all(QUERY_PRIMARY_DEVICE_ATTRIBUTE);
|
||||
out.end_buffering();
|
||||
}
|
||||
}
|
||||
@@ -2518,7 +2518,7 @@ fn handle_char_event(&mut self, injected_event: Option<CharEvent>) -> ControlFlo
|
||||
let mut out = Outputter::stdoutput().borrow_mut();
|
||||
out.begin_buffering();
|
||||
query_capabilities_via_dcs(out.by_ref());
|
||||
let _ = out.write(QUERY_PRIMARY_DEVICE_ATTRIBUTE);
|
||||
let _ = out.write_all(QUERY_PRIMARY_DEVICE_ATTRIBUTE);
|
||||
out.end_buffering();
|
||||
self.save_screen_state();
|
||||
self.blocking_wait = Some(BlockingWait::Startup(Queried::Twice));
|
||||
@@ -2556,12 +2556,12 @@ fn xtgettcap(out: &mut impl Write, cap: &str) {
|
||||
}
|
||||
|
||||
fn query_capabilities_via_dcs(out: &mut impl std::io::Write) {
|
||||
let _ = out.write(b"\x1b[?2026h"); // begin synchronized update
|
||||
let _ = out.write(b"\x1b[?1049h"); // enable alternative screen buffer
|
||||
let _ = out.write_all(b"\x1b[?2026h"); // begin synchronized update
|
||||
let _ = out.write_all(b"\x1b[?1049h"); // enable alternative screen buffer
|
||||
xtgettcap(out.by_ref(), "indn");
|
||||
xtgettcap(out.by_ref(), "cuu");
|
||||
let _ = out.write(b"\x1b[?1049l"); // disable alternative screen buffer
|
||||
let _ = out.write(b"\x1b[?2026l"); // end synchronized update
|
||||
let _ = out.write_all(b"\x1b[?1049l"); // disable alternative screen buffer
|
||||
let _ = out.write_all(b"\x1b[?2026l"); // end synchronized update
|
||||
}
|
||||
|
||||
impl<'a> Reader<'a> {
|
||||
|
||||
Reference in New Issue
Block a user