Skip to content

Commit 00bd869

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

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
@@ -852,11 +852,14 @@ _zsh_highlight_main_highlighter_highlight_list()
852852
fi
853853
fi
854854
continue
855-
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
855+
elif (( ! in_param )) &&
856+
[[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
856857
style=history-expansion
857-
elif [[ $arg[0,1] == $histchars[2,2] ]]; then
858+
elif (( ! in_param )) &&
859+
[[ $arg[0,1] == $histchars[2,2] ]]; then
858860
style=history-expansion
859-
elif [[ $arg[1,2] == '((' ]]; then
861+
elif (( ! in_param )) &&
862+
[[ $arg[1,2] == '((' ]]; then
860863
# Arithmetic evaluation.
861864
#
862865
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
@@ -871,14 +874,17 @@ _zsh_highlight_main_highlighter_highlight_list()
871874
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
872875
fi
873876
continue
874-
elif [[ $arg == '()' ]]; then
877+
elif (( ! in_param )) &&
878+
[[ $arg == '()' ]]; then
875879
# anonymous function
876880
style=reserved-word
877-
elif [[ $arg == $'\x28' ]]; then
881+
elif (( ! in_param )) &&
882+
[[ $arg == $'\x28' ]]; then
878883
# subshell
879884
style=reserved-word
880885
braces_stack='R'"$braces_stack"
881-
elif [[ $arg == $'\x29' ]]; then
886+
elif (( ! in_param )) &&
887+
[[ $arg == $'\x29' ]]; then
882888
# end of subshell or command substitution
883889
if _zsh_highlight_main__stack_pop 'S'; then
884890
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)