summaryrefslogtreecommitdiff
path: root/cli/repl.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2020-10-28 03:03:17 -0700
committerGitHub <noreply@github.com>2020-10-28 06:03:17 -0400
commit07359b795758179e1cffee23eae86e859898054b (patch)
treec0b3e412b24a61a06592979bd191b9d9a94cac9b /cli/repl.rs
parente01664d0ae6259022a901b0dea026ca350a49446 (diff)
fix(repl): don't hang on unpaired braces (#8151)
Previously, entering a single ']' would cause repl to forever accepting new lines, due to that `ValidationResult::Invalid` would actually be consumed by the editor itself while continue building the lines. Instead we should mark it as `Valid` and send the bad input for evaluation to get the proper error from V8. Before: ``` > ] (you can keep entering new line here, and it will never consume input until you Ctrl-C) ``` After: ``` > ] Uncaught SyntaxError: Unexpected token ']' > ```
Diffstat (limited to 'cli/repl.rs')
-rw-r--r--cli/repl.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/repl.rs b/cli/repl.rs
index 1cc866a6f..b2ea32670 100644
--- a/cli/repl.rs
+++ b/cli/repl.rs
@@ -171,11 +171,10 @@ impl Validator for Helper {
left
))))
}
- (None, c) => {
- return Ok(ValidationResult::Invalid(Some(format!(
- "Mismatched pairs: {:?} is unpaired",
- c
- ))))
+ (None, _) => {
+ // While technically invalid when unpaired, it should be V8's task to output error instead.
+ // Thus marked as valid with no info.
+ return Ok(ValidationResult::Valid(None));
}
},
_ => {}