Skip to content

Commit 3ca93f8

Browse files
committed
'main': Highlight literal semicolons in array assignments as errors.
Fixes the test added in the penultimate (grandparent) commit.
1 parent a4525a0 commit 3ca93f8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

highlighters/main/main-highlighter.zsh

+9-1
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,17 @@ _zsh_highlight_main_highlighter_highlight_list()
737737
else
738738
style=unknown-token
739739
fi
740-
if [[ $arg == (';'|$'\n') ]] && $in_array_assignment; then
740+
if [[ $arg == $'\n' ]] && $in_array_assignment; then
741741
# literal newline inside an array assignment
742742
next_word=':regular:'
743+
elif [[ $arg == ';' ]] && $in_array_assignment; then
744+
# literal semicolon inside an array assignment
745+
#
746+
# This is parsed the same way as a literal newline. Nevertheless,
747+
# highlight it as an error since it's probably unintended. Compare
748+
# issue #691.
749+
next_word=':regular:'
750+
style=unknown-token
743751
else
744752
next_word=':start:'
745753
highlight_glob=true

highlighters/main/test-data/array-cmdsep2.zsh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ BUFFER=$'a=( foo ; bar )'
3333
expected_region_highlight=(
3434
'1 3 assign' # a=(
3535
'5 7 default' # foo
36-
'9 9 unknown-token "fixed in the after-next (grandchild) commit"' # ;
36+
'9 9 unknown-token' # ; (not commandseparator; see highlighter source code)
3737
'11 13 default' # bar
3838
'15 15 assign' # )
3939
)

0 commit comments

Comments
 (0)