aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse_util.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-14 00:01:26 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-14 00:02:18 -0800
commitdc8014562b3128dc3725a822c32a24d6a212180e (patch)
tree6c9f25600ca1353aa356a7dca486b9e461cacb4d /parse_util.cpp
parentb9394b9599c2449a1f542979eba6c0dc51e13b21 (diff)
Fix for issue where unterminated quotes would attempt to be executed,
instead of continuing edit onto the next line.
Diffstat (limited to 'parse_util.cpp')
-rw-r--r--parse_util.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/parse_util.cpp b/parse_util.cpp
index 491e4732..46621717 100644
--- a/parse_util.cpp
+++ b/parse_util.cpp
@@ -992,9 +992,27 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, pars
// We detect this via an 'end_command' block without source
bool has_unclosed_block = false;
+ // Whether there's an unclosed quote, and therefore unfinished
+ bool has_unclosed_quote = false;
+
// Parse the input string into a parse tree
// Some errors are detected here
bool parsed = parse_tree_from_string(buff_src, parse_flag_leave_unterminated, &node_tree, &parse_errors);
+
+ for (size_t i=0; i < parse_errors.size(); i++)
+ {
+ if (parse_errors.at(i).code == parse_error_tokenizer_unterminated_quote)
+ {
+ // Remove this error, since we don't consider it a real error
+ has_unclosed_quote = true;
+ parse_errors.erase(parse_errors.begin() + i);
+ i--;
+ }
+ }
+ // #1238: If the only error was unterminated quote, then consider this to have parsed successfully. A better fix would be to have parse_tree_from_string return this information directly (but it would be a shame to munge up its nice bool return).
+ if (parse_errors.empty() && has_unclosed_quote)
+ parsed = true;
+
if (! parsed)
{
errored = true;
@@ -1120,7 +1138,7 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, pars
if (errored)
res |= PARSER_TEST_ERROR;
- if (has_unclosed_block)
+ if (has_unclosed_block || has_unclosed_quote)
res |= PARSER_TEST_INCOMPLETE;
if (out_errors)