@@ -431,7 +431,7 @@ _zsh_highlight_main_highlighter_highlight_list()
431431 # Usually 'alias' but set to 'unknown-token' if any word expanded from
432432 # the alias would be highlighted as unknown-token
433433 # param_style is analogous for parameter expansions
434- local alias_style param_style last_arg arg buf=$4 highlight_glob=true style
434+ local alias_style param_style last_arg arg buf=$4 highlight_glob=true saw_assignment=false style
435435 local in_array_assignment=false # true between 'a=(' and the matching ')'
436436 # in_alias is equal to the number of shifts needed until arg=args[1] pops an
437437 # arg from BUFFER and not added by an alias.
@@ -556,6 +556,7 @@ _zsh_highlight_main_highlighter_highlight_list()
556556 # $style how to highlight $arg
557557 # $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
558558 # $highlight_glob boolean flag for "'noglob' is in effect"
559+ # $saw_assignment boolean flag for "was preceded by an assignment"
559560 #
560561 style=unknown-token
561562 if [[ $this_word == * ' :start:' * ]]; then
@@ -826,6 +827,7 @@ _zsh_highlight_main_highlighter_highlight_list()
826827 else
827828 next_word=' :start:'
828829 highlight_glob=true
830+ saw_assignment=false
829831 if [[ $arg != ' |' && $arg != ' |&' ]]; then
830832 next_word+=' :start_of_pipeline:'
831833 fi
@@ -835,6 +837,7 @@ _zsh_highlight_main_highlighter_highlight_list()
835837 # try-always construct
836838 style=reserved-word # de facto a reserved word, although not de jure
837839 highlight_glob=true
840+ saw_assignment=false
838841 next_word=' :start::start_of_pipeline:' # only left brace is allowed, apparently
839842 elif ! (( in_redirection)) && [[ $this_word == * ' :start:' * ]]; then # $arg is the command word
840843 if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg ; then
@@ -930,6 +933,9 @@ _zsh_highlight_main_highlighter_highlight_list()
930933 fi
931934 ;;
932935 esac
936+ if $saw_assignment && [[ $style != unknown-token ]]; then
937+ style=unknown-token
938+ fi
933939 ;;
934940 (' suffix alias' )
935941 style=suffix-alias
@@ -947,6 +953,7 @@ _zsh_highlight_main_highlighter_highlight_list()
947953 (none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
948954 _zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
949955 local i=$(( arg[(i)= ] + 1 ))
956+ saw_assignment=true
950957 if [[ $arg [i] == ' (' ]]; then
951958 in_array_assignment=true
952959 else
@@ -972,6 +979,7 @@ _zsh_highlight_main_highlighter_highlight_list()
972979 [[ $arg [0,1] == $histchars [2,2] ]]; then
973980 style=history-expansion
974981 elif (( ! in_param )) &&
982+ ! $saw_assignment &&
975983 [[ $arg [1,2] == ' ((' ]]; then
976984 # Arithmetic evaluation.
977985 #
@@ -992,6 +1000,7 @@ _zsh_highlight_main_highlighter_highlight_list()
9921000 # anonymous function
9931001 style=reserved-word
9941002 elif (( ! in_param )) &&
1003+ ! $saw_assignment &&
9951004 [[ $arg == $' \x28 ' ]]; then
9961005 # subshell
9971006 style=reserved-word
0 commit comments