@@ -431,7 +431,7 @@ _zsh_highlight_main_highlighter_highlight_list()
431
431
# Usually 'alias' but set to 'unknown-token' if any word expanded from
432
432
# the alias would be highlighted as unknown-token
433
433
# 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
435
435
local in_array_assignment=false # true between 'a=(' and the matching ')'
436
436
# in_alias is equal to the number of shifts needed until arg=args[1] pops an
437
437
# arg from BUFFER and not added by an alias.
@@ -556,6 +556,7 @@ _zsh_highlight_main_highlighter_highlight_list()
556
556
# $style how to highlight $arg
557
557
# $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
558
558
# $highlight_glob boolean flag for "'noglob' is in effect"
559
+ # $saw_assignment boolean flag for "was preceded by an assignment"
559
560
#
560
561
style=unknown-token
561
562
if [[ $this_word == * ' :start:' * ]]; then
@@ -826,6 +827,7 @@ _zsh_highlight_main_highlighter_highlight_list()
826
827
else
827
828
next_word=' :start:'
828
829
highlight_glob=true
830
+ saw_assignment=false
829
831
if [[ $arg != ' |' && $arg != ' |&' ]]; then
830
832
next_word+=' :start_of_pipeline:'
831
833
fi
@@ -835,6 +837,7 @@ _zsh_highlight_main_highlighter_highlight_list()
835
837
# try-always construct
836
838
style=reserved-word # de facto a reserved word, although not de jure
837
839
highlight_glob=true
840
+ saw_assignment=false
838
841
next_word=' :start::start_of_pipeline:' # only left brace is allowed, apparently
839
842
elif ! (( in_redirection)) && [[ $this_word == * ' :start:' * ]]; then # $arg is the command word
840
843
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg ; then
@@ -930,6 +933,9 @@ _zsh_highlight_main_highlighter_highlight_list()
930
933
fi
931
934
;;
932
935
esac
936
+ if $saw_assignment && [[ $style != unknown-token ]]; then
937
+ style=unknown-token
938
+ fi
933
939
;;
934
940
(' suffix alias' )
935
941
style=suffix-alias
@@ -947,6 +953,7 @@ _zsh_highlight_main_highlighter_highlight_list()
947
953
(none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
948
954
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
949
955
local i=$(( arg[(i)= ] + 1 ))
956
+ saw_assignment=true
950
957
if [[ $arg [i] == ' (' ]]; then
951
958
in_array_assignment=true
952
959
else
@@ -972,6 +979,7 @@ _zsh_highlight_main_highlighter_highlight_list()
972
979
[[ $arg [0,1] == $histchars [2,2] ]]; then
973
980
style=history-expansion
974
981
elif (( ! in_param )) &&
982
+ ! $saw_assignment &&
975
983
[[ $arg [1,2] == ' ((' ]]; then
976
984
# Arithmetic evaluation.
977
985
#
@@ -992,6 +1000,7 @@ _zsh_highlight_main_highlighter_highlight_list()
992
1000
# anonymous function
993
1001
style=reserved-word
994
1002
elif (( ! in_param )) &&
1003
+ ! $saw_assignment &&
995
1004
[[ $arg == $' \x28 ' ]]; then
996
1005
# subshell
997
1006
style=reserved-word
0 commit comments