Skip to content

Commit f729726

Browse files
committed
'main': Do not look for metacharacters in parameter expansions.
Fixes the bug the previous commit added a test for.
1 parent f490b7c commit f729726

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

highlighters/main/main-highlighter.zsh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,14 @@ _zsh_highlight_main_highlighter_highlight_list()
861861
fi
862862
fi
863863
continue
864-
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
864+
elif (( ! in_param )) &&
865+
[[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
865866
style=history-expansion
866-
elif [[ $arg[0,1] == $histchars[2,2] ]]; then
867+
elif (( ! in_param )) &&
868+
[[ $arg[0,1] == $histchars[2,2] ]]; then
867869
style=history-expansion
868-
elif [[ $arg[1,2] == '((' ]]; then
870+
elif (( ! in_param )) &&
871+
[[ $arg[1,2] == '((' ]]; then
869872
# Arithmetic evaluation.
870873
#
871874
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
@@ -880,14 +883,17 @@ _zsh_highlight_main_highlighter_highlight_list()
880883
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
881884
fi
882885
continue
883-
elif [[ $arg == '()' ]]; then
886+
elif (( ! in_param )) &&
887+
[[ $arg == '()' ]]; then
884888
# anonymous function
885889
style=reserved-word
886-
elif [[ $arg == $'\x28' ]]; then
890+
elif (( ! in_param )) &&
891+
[[ $arg == $'\x28' ]]; then
887892
# subshell
888893
style=reserved-word
889894
braces_stack='R'"$braces_stack"
890-
elif [[ $arg == $'\x29' ]]; then
895+
elif (( ! in_param )) &&
896+
[[ $arg == $'\x29' ]]; then
891897
# end of subshell or command substitution
892898
if _zsh_highlight_main__stack_pop 'S'; then
893899
REPLY=$start_pos

highlighters/main/test-data/parameter-expansion-untokenized1.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ local x="()"
3333
BUFFER=$'$x ls'
3434

3535
expected_region_highlight=(
36-
'1 2 unknown-token "fixed in the next commit"' # $x
36+
'1 2 unknown-token' # $x
3737
'4 5 command' # ls
3838
)

highlighters/main/test-data/parameter-expansion-untokenized2.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ local x="^foo^bar"
3333
BUFFER=$'$x ls'
3434

3535
expected_region_highlight=(
36-
'1 2 unknown-token "fixed in the next commit"' # $x
36+
'1 2 unknown-token' # $x
3737
'4 5 default' # ls
3838
)

0 commit comments

Comments
 (0)