Fix part of issue #238, "fd redirections at command word".

This fixes fd's specified by a (single) digit.  The named fd syntax remains an XFail.
This commit is contained in:
Daniel Shahaf 2015-11-29 03:11:50 +00:00
parent 48ecd29180
commit 73ee7c1f6c
2 changed files with 5 additions and 4 deletions

View file

@ -320,7 +320,8 @@ _zsh_highlight_main_highlighter()
else else
style=$ZSH_HIGHLIGHT_STYLES[unknown-token] style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
fi fi
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then elif [[ $arg == (<0-9>|)(\<|\>)* ]]; then
# A '<' or '>', possibly followed by a digit
style=$ZSH_HIGHLIGHT_STYLES[redirection] style=$ZSH_HIGHLIGHT_STYLES[redirection]
(( in_redirection=2 )) (( in_redirection=2 ))
elif [[ $arg[1,2] == '((' ]]; then elif [[ $arg[1,2] == '((' ]]; then
@ -389,7 +390,7 @@ _zsh_highlight_main_highlighter()
else else
style=$ZSH_HIGHLIGHT_STYLES[unknown-token] style=$ZSH_HIGHLIGHT_STYLES[unknown-token]
fi fi
elif [[ $arg[1] == '<' || $arg[1] == '>' ]]; then elif [[ $arg == (<0-9>|)(\<|\>)* ]]; then
style=$ZSH_HIGHLIGHT_STYLES[redirection] style=$ZSH_HIGHLIGHT_STYLES[redirection]
(( in_redirection=2 )) (( in_redirection=2 ))
else else

View file

@ -32,9 +32,9 @@ BUFFER='sudo 2>./. -u otheruser ls'
expected_region_highlight=( expected_region_highlight=(
"1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo "1 4 $ZSH_HIGHLIGHT_STYLES[precommand]" # sudo
"6 7 $ZSH_HIGHLIGHT_STYLES[redirection] 'issue #238'" # 2> "6 7 $ZSH_HIGHLIGHT_STYLES[redirection]" # 2>
"8 10 $ZSH_HIGHLIGHT_STYLES[path]" # ./. # a 3-character path, for alignment with sudo-redirection2.zsh "8 10 $ZSH_HIGHLIGHT_STYLES[path]" # ./. # a 3-character path, for alignment with sudo-redirection2.zsh
"12 13 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u "12 13 $ZSH_HIGHLIGHT_STYLES[single-hyphen-option]" # -u
"15 23 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser "15 23 $ZSH_HIGHLIGHT_STYLES[default]" # otheruser
"25 26 $ZSH_HIGHLIGHT_STYLES[command] 'issue #238'" # ls "25 26 $ZSH_HIGHLIGHT_STYLES[command]" # ls
) )