Skip to content

Commit fb074f1

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

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
@@ -860,11 +860,14 @@ _zsh_highlight_main_highlighter_highlight_list()
860860
fi
861861
fi
862862
continue
863-
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
863+
elif (( ! in_param )) &&
864+
[[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
864865
style=history-expansion
865-
elif [[ $arg[0,1] == $histchars[2,2] ]]; then
866+
elif (( ! in_param )) &&
867+
[[ $arg[0,1] == $histchars[2,2] ]]; then
866868
style=history-expansion
867-
elif [[ $arg[1,2] == '((' ]]; then
869+
elif (( ! in_param )) &&
870+
[[ $arg[1,2] == '((' ]]; then
868871
# Arithmetic evaluation.
869872
#
870873
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
@@ -879,14 +882,17 @@ _zsh_highlight_main_highlighter_highlight_list()
879882
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
880883
fi
881884
continue
882-
elif [[ $arg == '()' ]]; then
885+
elif (( ! in_param )) &&
886+
[[ $arg == '()' ]]; then
883887
# anonymous function
884888
style=reserved-word
885-
elif [[ $arg == $'\x28' ]]; then
889+
elif (( ! in_param )) &&
890+
[[ $arg == $'\x28' ]]; then
886891
# subshell
887892
style=reserved-word
888893
braces_stack='R'"$braces_stack"
889-
elif [[ $arg == $'\x29' ]]; then
894+
elif (( ! in_param )) &&
895+
[[ $arg == $'\x29' ]]; then
890896
# end of subshell or command substitution
891897
if _zsh_highlight_main__stack_pop 'S'; then
892898
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)