From 3ca93f864fb61b32db74f1249b3a8e47806b6ed8 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 15 Mar 2020 14:19:23 +0000 Subject: [PATCH] 'main': Highlight literal semicolons in array assignments as errors. Fixes the test added in the penultimate (grandparent) commit. --- highlighters/main/main-highlighter.zsh | 10 +++++++++- highlighters/main/test-data/array-cmdsep2.zsh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 7b9fbd3..04b6ece 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -737,9 +737,17 @@ _zsh_highlight_main_highlighter_highlight_list() else style=unknown-token fi - if [[ $arg == (';'|$'\n') ]] && $in_array_assignment; then + if [[ $arg == $'\n' ]] && $in_array_assignment; then # literal newline inside an array assignment next_word=':regular:' + elif [[ $arg == ';' ]] && $in_array_assignment; then + # literal semicolon inside an array assignment + # + # This is parsed the same way as a literal newline. Nevertheless, + # highlight it as an error since it's probably unintended. Compare + # issue #691. + next_word=':regular:' + style=unknown-token else next_word=':start:' highlight_glob=true diff --git a/highlighters/main/test-data/array-cmdsep2.zsh b/highlighters/main/test-data/array-cmdsep2.zsh index 8b4a2eb..2d2c865 100644 --- a/highlighters/main/test-data/array-cmdsep2.zsh +++ b/highlighters/main/test-data/array-cmdsep2.zsh @@ -33,7 +33,7 @@ BUFFER=$'a=( foo ; bar )' expected_region_highlight=( '1 3 assign' # a=( '5 7 default' # foo - '9 9 unknown-token "fixed in the after-next (grandchild) commit"' # ; + '9 9 unknown-token' # ; (not commandseparator; see highlighter source code) '11 13 default' # bar '15 15 assign' # ) )