From 2a1fd421bda502cc183415163eea1a216da79576 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 25 Nov 2013 00:48:01 -0800 Subject: [PATCH] Correctly detect unbalanced 'end' in syntax highlighting --- fish_tests.cpp | 8 +++++++- parse_tree.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fish_tests.cpp b/fish_tests.cpp index 153ca70ea..b5bc3a20e 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -2263,9 +2263,15 @@ static void test_highlighting(void) {L"param2", HIGHLIGHT_PARAM}, {NULL, -1} }; + + const highlight_component_t components9[] = + { + {L"end", HIGHLIGHT_ERROR}, + {NULL, -1} + }; - const highlight_component_t *tests[] = {components1, components2, components3, components4, components5, components6, components7, components8}; + const highlight_component_t *tests[] = {components1, components2, components3, components4, components5, components6, components7, components8, components9}; for (size_t which = 0; which < sizeof tests / sizeof *tests; which++) { const highlight_component_t *components = tests[which]; diff --git a/parse_tree.cpp b/parse_tree.cpp index 97421dab1..24cf45986 100644 --- a/parse_tree.cpp +++ b/parse_tree.cpp @@ -862,7 +862,7 @@ bool parse_t::parse_internal(const wcstring &str, parse_tree_flags_t parse_flags if (parse_flags & parse_flag_continue_after_error) { /* Mark a special error token, and then keep going */ - const parse_token_t token = {parse_special_type_parse_error, parse_keyword_none, -1, -1}; + const parse_token_t token = {parse_special_type_parse_error, parse_keyword_none, false, queue[0].source_start, queue[0].source_length}; this->parser->accept_tokens(token, kInvalidToken); this->parser->reset_symbols(); }