Flush buffer on write and ewrite

This commit is contained in:
Metrowai 2023-05-16 21:17:25 -07:00
parent d2ed3bdd5d
commit 4904842e96

View file

@ -1,6 +1,8 @@
use blocking::unblock;
use dialoguer::{theme::ColorfulTheme, Confirm, Input, MultiSelect, Select};
use mlua::prelude::*;
use std::io;
use std::io::prelude::*;
use crate::lua::{
stdio::{
@ -27,10 +29,12 @@ pub fn create(lua: &'static Lua) -> LuaResult<LuaTable> {
})?
.with_function("write", |_, s: String| {
print!("{s}");
io::stdout().flush().expect("Could not flush stdout");
Ok(())
})?
.with_function("ewrite", |_, s: String| {
eprint!("{s}");
io::stderr().flush().expect("Could not flush stderr");
Ok(())
})?
.with_async_function("prompt", |_, options: PromptOptions| {