mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-02-06 09:55:31 +08:00
'main': Don't match redirection operators in command substitutions as <-> number range globs. Fixes #483.
This commit is contained in:
parent
901063aa0f
commit
0458b0c16f
@ -801,6 +801,9 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
local i path_eligible style
|
local i path_eligible style
|
||||||
path_eligible=1
|
path_eligible=1
|
||||||
|
|
||||||
|
local -a match mbegin mend
|
||||||
|
local MATCH; integer MBEGIN MEND
|
||||||
|
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos default
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos default
|
||||||
for (( i = 1 ; i <= end_pos - start_pos ; i += 1 )); do
|
for (( i = 1 ; i <= end_pos - start_pos ; i += 1 )); do
|
||||||
case "$arg[$i]" in
|
case "$arg[$i]" in
|
||||||
@ -822,14 +825,16 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
elif [[ $arg[i+1] == [*@#?-$!] ]]; then
|
elif [[ $arg[i+1] == [*@#?-$!] ]]; then
|
||||||
(( i += 1 ))
|
(( i += 1 ))
|
||||||
fi;;
|
fi;;
|
||||||
[*?]|\<)
|
*)
|
||||||
# The '<' is for the <-> globbing syntax. (This function doesn't get called on redirection tokens.)
|
if $highlight_glob && [[ ${arg[$i]} == [*?] || ${arg:$i-1} == \<[0-9]#-[0-9]#\>* ]]; then
|
||||||
if $highlight_glob; then
|
(( i += $#MATCH - 1 ))
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos globbing
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos globbing
|
||||||
path_eligible=0
|
path_eligible=0
|
||||||
break
|
break
|
||||||
fi;;
|
else
|
||||||
*) continue;;
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
BUFFER='print <-> x<-> <foo2-3>'
|
BUFFER='print <-> x<->y <foo2-3>'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 5 builtin' # print
|
'1 5 builtin' # print
|
||||||
'7 9 globbing' # <->
|
'7 9 globbing' # <->
|
||||||
'11 14 globbing' # x<->
|
'11 15 globbing' # x<->
|
||||||
'16 16 redirection' # <
|
'17 17 redirection' # <
|
||||||
'17 22 default' # foo2-3 (the filename)
|
'18 23 default' # foo2-3 (the filename)
|
||||||
'23 23 redirection' # >
|
'24 24 redirection' # >
|
||||||
)
|
)
|
||||||
|
@ -32,5 +32,5 @@ BUFFER=$': $(<foo)'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 builtin' # :
|
'1 1 builtin' # :
|
||||||
'3 9 default "issue #483"' # $(<foo)
|
'3 9 default' # $(<foo)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user