From a18baff63267343c76c19e261287e68e05924aed Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 20 Mar 2021 21:35:45 +0530 Subject: fix empty command exec bug --- src/app.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/app.rs b/src/app.rs index 8543c85..063f54f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -272,16 +272,15 @@ impl<'ctx> AppState<'ctx> { } fn eval_command(&mut self) { - self.command_box.hist_append(); - match self.command_box.text.as_str() { - "(save)" => { - let image = self.export(); - let encoded = image.encode().unwrap(); - let mut buffer = File::create("test.obi").unwrap(); - eprintln!("writing to file"); - buffer.write_all(&encoded[..]).unwrap(); - } - _ => {} + if let Some(path) = self.command_box.text.strip_prefix("(save ") { + let image = self.export(); + let encoded = image.encode().unwrap(); + let mut buffer = File::create(path).unwrap(); + eprintln!("writing to file"); + buffer.write_all(&encoded[..]).unwrap(); + self.command_box.hist_append(); + } else { + eprintln!("cmd: {}", self.command_box.text); } self.command_box.clear(); self.mode = Mode::Draw; -- cgit v1.2.3