mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 18:15:04 +02:00
refactor all write_alls to ensure flushing (#5567)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use std::io::Result;
|
||||
use std::io::{Result, Write};
|
||||
|
||||
pub fn enable_vt_processing() -> Result<()> {
|
||||
#[cfg(windows)]
|
||||
@ -23,3 +23,23 @@ pub fn enable_vt_processing() -> Result<()> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn stdout_write_all_and_flush(output: String) -> Result<()> {
|
||||
let stdout = std::io::stdout();
|
||||
let ret = match stdout.lock().write_all(output.as_bytes()) {
|
||||
Ok(_) => Ok(stdout.lock().flush()?),
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
|
||||
ret
|
||||
}
|
||||
|
||||
pub fn stdout_write_all_as_binary_and_flush(output: &[u8]) -> Result<()> {
|
||||
let stdout = std::io::stdout();
|
||||
let ret = match stdout.lock().write_all(output) {
|
||||
Ok(_) => Ok(stdout.lock().flush()?),
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
|
||||
ret
|
||||
}
|
||||
|
Reference in New Issue
Block a user