fix: don't add newline when no value is returned

This commit is contained in:
əlemi 2023-04-06 05:25:58 +02:00
parent 690cb379d7
commit 9541172174
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -75,12 +75,14 @@ impl LuaRepl {
CR => { CR => {
match lua.load(&self.buffer).eval::<MultiValue>() { match lua.load(&self.buffer).eval::<MultiValue>() {
Ok(values) => { Ok(values) => {
let mut once = false;
for val in values { for val in values {
once = true;
self.console.send( self.console.send(
format!("=({}) {}", val.type_name(), pretty_lua(val)) format!("=({}) {}", val.type_name(), pretty_lua(val))
)?; )?;
} }
self.console.send("\n@> ".into())?; self.console.send(format!("{}@> ", if once { "\n" } else { "" }))?;
self.buffer = String::new(); self.buffer = String::new();
}, },
Err(e) => { Err(e) => {