From 223a53cf9a65b63afa3acdc755ebcc8fc4a15269 Mon Sep 17 00:00:00 2001 From: Emily Toop Date: Thu, 1 Jun 2017 13:49:06 +0100 Subject: [PATCH] improve the handling of complete and incomplete commands in input.rs --- tools/cli/src/mentat_cli/input.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tools/cli/src/mentat_cli/input.rs b/tools/cli/src/mentat_cli/input.rs index 45d2cebc..d1805243 100644 --- a/tools/cli/src/mentat_cli/input.rs +++ b/tools/cli/src/mentat_cli/input.rs @@ -158,20 +158,17 @@ impl InputReader { } }; - match cmd { - Command::Query(_) | - Command::Transact(_) if !cmd.is_complete().0 => { - // a query or transact is complete if it contains a valid edn. - // if the command is not complete, ask for more from the repl and remember - // which type of command we've found here. - self.in_process_cmd = Some(cmd); - Ok(More) - }, - _ => { - self.buffer.clear(); - self.in_process_cmd = None; - Ok(InputResult::MetaCommand(cmd)) - } + let (is_complete, _) = cmd.is_complete(); + if is_complete { + self.buffer.clear(); + self.in_process_cmd = None; + Ok(InputResult::MetaCommand(cmd)) + } else { + // a query or transact is complete if it contains a valid edn. + // if the command is not complete, ask for more from the repl and remember + // which type of command we've found here. + self.in_process_cmd = Some(cmd); + Ok(More) } }