mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-02-06 09:55:31 +08:00
main: Highlight the value of an assignment
This commit is contained in:
parent
c06e5e95dc
commit
932eb380e2
@ -610,6 +610,8 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
hashed) style=hashed-command;;
|
hashed) style=hashed-command;;
|
||||||
none) if _zsh_highlight_main_highlighter_check_assign; then
|
none) if _zsh_highlight_main_highlighter_check_assign; then
|
||||||
style=assign
|
style=assign
|
||||||
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
|
already_added=1
|
||||||
local i=$(( arg[(i)=] + 1 ))
|
local i=$(( arg[(i)=] + 1 ))
|
||||||
if [[ $arg[i] == '(' ]]; then
|
if [[ $arg[i] == '(' ]]; then
|
||||||
in_array_assignment=true
|
in_array_assignment=true
|
||||||
@ -617,6 +619,9 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# assignment to a scalar parameter.
|
# assignment to a scalar parameter.
|
||||||
# (For array assignments, the command doesn't start until the ")" token.)
|
# (For array assignments, the command doesn't start until the ")" token.)
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
|
if (( start_pos + i <= end_pos )); then
|
||||||
|
highlight_glob=false _zsh_highlight_main_highlighter_highlight_argument $i
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
|
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
|
||||||
style=history-expansion
|
style=history-expansion
|
||||||
|
@ -27,9 +27,12 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
touch foo
|
||||||
BUFFER='42=foo 43+=bar'
|
BUFFER='42=foo 43+=bar'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 6 assign" # 42=foo
|
"1 6 assign" # 42=foo
|
||||||
|
"4 6 path" # foo
|
||||||
"8 14 assign" # 43+=bar
|
"8 14 assign" # 43+=bar
|
||||||
|
"12 14 default" # bar
|
||||||
)
|
)
|
||||||
|
@ -35,4 +35,5 @@ expected_region_highlight=(
|
|||||||
"10 14 default" # world
|
"10 14 default" # world
|
||||||
"15 15 assign" # )
|
"15 15 assign" # )
|
||||||
"17 20 assign" # b=42
|
"17 20 assign" # b=42
|
||||||
|
"19 20 default" # 42
|
||||||
)
|
)
|
||||||
|
@ -31,5 +31,6 @@ BUFFER='a=foo( bar ) :'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 12 assign' # a=foo( bar )
|
'1 12 assign' # a=foo( bar )
|
||||||
|
'3 12 default' # foo( bar )
|
||||||
'14 14 builtin' # :
|
'14 14 builtin' # :
|
||||||
)
|
)
|
||||||
|
@ -31,5 +31,6 @@ BUFFER='a=foo\( :'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 7 assign' # a=foo\(
|
'1 7 assign' # a=foo\(
|
||||||
|
'3 7 default' # foo\(
|
||||||
'9 9 builtin' # :
|
'9 9 builtin' # :
|
||||||
)
|
)
|
||||||
|
@ -31,6 +31,7 @@ BUFFER='A=1; echo hello world'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 3 assign" # A=1
|
"1 3 assign" # A=1
|
||||||
|
"3 3 default" # 1
|
||||||
"4 4 commandseparator" # ;
|
"4 4 commandseparator" # ;
|
||||||
"6 9 builtin" # echo
|
"6 9 builtin" # echo
|
||||||
"11 15 default" # hello
|
"11 15 default" # hello
|
||||||
|
@ -32,5 +32,6 @@ BUFFER='(A=1)'
|
|||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 1 reserved-word" # (
|
"1 1 reserved-word" # (
|
||||||
"2 4 assign" # A=1
|
"2 4 assign" # A=1
|
||||||
|
"4 4 default" # 1
|
||||||
"5 5 reserved-word" # )
|
"5 5 reserved-word" # )
|
||||||
)
|
)
|
||||||
|
@ -31,6 +31,7 @@ BUFFER='A=1 b=("foo" bar)'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 3 assign" # A=1
|
"1 3 assign" # A=1
|
||||||
|
"3 3 default" # 1
|
||||||
"5 7 assign" # b=(
|
"5 7 assign" # b=(
|
||||||
"8 12 default" # "foo"
|
"8 12 default" # "foo"
|
||||||
"8 12 double-quoted-argument" # "foo"
|
"8 12 double-quoted-argument" # "foo"
|
||||||
|
Loading…
Reference in New Issue
Block a user