main: Do not highlight a redirection target as an option

This commit is contained in:
Matthew Martin 2018-10-01 18:14:56 -04:00
parent b075147888
commit 2f03b6d704

View file

@ -829,7 +829,7 @@ _zsh_highlight_main_highlighter_highlight_list()
style=unknown-token style=unknown-token
fi fi
else else
_zsh_highlight_main_highlighter_highlight_argument 1 _zsh_highlight_main_highlighter_highlight_argument 1 $(( 1 - in_redirection ))
continue continue
fi fi
;; ;;
@ -926,9 +926,10 @@ _zsh_highlight_main_highlighter_check_path()
# Highlight an argument and possibly special chars in quotes starting at $1 in $arg # Highlight an argument and possibly special chars in quotes starting at $1 in $arg
# This command will at least highlight $1 to end_pos with the default style # This command will at least highlight $1 to end_pos with the default style
# If $2 is set to 0, the argument cannot be highlighted as an option.
_zsh_highlight_main_highlighter_highlight_argument() _zsh_highlight_main_highlighter_highlight_argument()
{ {
local base_style=default i=$1 path_eligible=1 ret start style local base_style=default i=$1 option_eligible=${2:-1} path_eligible=1 ret start style
local -a highlights local -a highlights
local -a match mbegin mend local -a match mbegin mend
@ -936,12 +937,14 @@ _zsh_highlight_main_highlighter_highlight_argument()
case "$arg[i]" in case "$arg[i]" in
'-') '-')
if (( option_eligible )); then
if [[ $arg[i+1] == - ]]; then if [[ $arg[i+1] == - ]]; then
base_style=double-hyphen-option base_style=double-hyphen-option
else else
base_style=single-hyphen-option base_style=single-hyphen-option
fi fi
path_eligible=0 path_eligible=0
fi
;; ;;
'=') '=')
if [[ $arg[i+1] == $'\x28' ]]; then if [[ $arg[i+1] == $'\x28' ]]; then