improve the handling of complete and incomplete commands in input.rs

This commit is contained in:
Emily Toop 2017-06-01 13:49:06 +01:00
parent 831f7032ce
commit 223a53cf9a

View file

@ -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)
}
}