'main': Do not look for metacharacters in parameter expansions.

Fixes the bug the previous commit added a test for.
This commit is contained in:
Daniel Shahaf 2020-02-21 10:19:51 +00:00
parent f490b7cb95
commit f729726300
3 changed files with 14 additions and 8 deletions

View file

@ -861,11 +861,14 @@ _zsh_highlight_main_highlighter_highlight_list()
fi
fi
continue
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
elif (( ! in_param )) &&
[[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
style=history-expansion
elif [[ $arg[0,1] == $histchars[2,2] ]]; then
elif (( ! in_param )) &&
[[ $arg[0,1] == $histchars[2,2] ]]; then
style=history-expansion
elif [[ $arg[1,2] == '((' ]]; then
elif (( ! in_param )) &&
[[ $arg[1,2] == '((' ]]; then
# Arithmetic evaluation.
#
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
@ -880,14 +883,17 @@ _zsh_highlight_main_highlighter_highlight_list()
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
fi
continue
elif [[ $arg == '()' ]]; then
elif (( ! in_param )) &&
[[ $arg == '()' ]]; then
# anonymous function
style=reserved-word
elif [[ $arg == $'\x28' ]]; then
elif (( ! in_param )) &&
[[ $arg == $'\x28' ]]; then
# subshell
style=reserved-word
braces_stack='R'"$braces_stack"
elif [[ $arg == $'\x29' ]]; then
elif (( ! in_param )) &&
[[ $arg == $'\x29' ]]; then
# end of subshell or command substitution
if _zsh_highlight_main__stack_pop 'S'; then
REPLY=$start_pos

View file

@ -33,6 +33,6 @@ local x="()"
BUFFER=$'$x ls'
expected_region_highlight=(
'1 2 unknown-token "fixed in the next commit"' # $x
'1 2 unknown-token' # $x
'4 5 command' # ls
)

View file

@ -33,6 +33,6 @@ local x="^foo^bar"
BUFFER=$'$x ls'
expected_region_highlight=(
'1 2 unknown-token "fixed in the next commit"' # $x
'1 2 unknown-token' # $x
'4 5 default' # ls
)