repl treats whens as incomplete until blank line

This commit is contained in:
Richard Feldman 2022-10-30 13:38:22 -04:00
parent fccc2ed497
commit eebf973f11
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
2 changed files with 26 additions and 17 deletions

View file

@ -442,6 +442,11 @@ pub fn is_incomplete(input: &str) -> bool {
//
// So it's Incomplete until you've pressed Enter again (causing the input to end in "\n")
ParseOutcome::ValueDef(ValueDef::Annotation(_, _)) if !input.ends_with('\n') => true,
ParseOutcome::Expr(Expr::When(_, _)) => {
// There might be lots of `when` branches, so don't assume the user is done entering
// them until they enter a blank line!
!input.ends_with('\n')
}
ParseOutcome::Empty
| ParseOutcome::Help
| ParseOutcome::Exit