'main': Add an auxiliary variable for readability.

This commit is contained in:
Daniel Shahaf 2020-03-16 20:28:14 +00:00 committed by Daniel Shahaf
parent 5545fb9ab2
commit 3f930fb0c1

View File

@ -1123,6 +1123,12 @@ _zsh_highlight_main_highlighter_check_path()
local expanded_path="$REPLY" tmp_path local expanded_path="$REPLY" tmp_path
integer in_command_position=$2 integer in_command_position=$2
if [[ $zsyh_user_options[autocd] == on ]]; then
integer autocd=1
else
integer autocd=0
fi
if (( in_command_position )); then if (( in_command_position )); then
REPLY=arg0 REPLY=arg0
else else
@ -1150,7 +1156,7 @@ _zsh_highlight_main_highlighter_check_path()
done done
if (( in_command_position )); then if (( in_command_position )); then
if [[ -x $expanded_path ]] && [[ $zsyh_user_options[autocd] == on || ! -d $expanded_path ]]; then if [[ -x $expanded_path ]] && { (( autocd )) || [[ ! -d $expanded_path ]] }; then
return 0 return 0
fi fi
else else
@ -1160,8 +1166,7 @@ _zsh_highlight_main_highlighter_check_path()
fi fi
# Search the path in CDPATH # Search the path in CDPATH
if [[ $expanded_path != /* ]] && if [[ $expanded_path != /* ]] && (( autocd || ! in_command_position )); then
{ (( ! in_command_position )) || [[ $zsyh_user_options[autocd] == on ]] }; then
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here. # TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
local cdpath_dir local cdpath_dir
for cdpath_dir in $cdpath ; do for cdpath_dir in $cdpath ; do