Skip to content

Commit e0849a8

Browse files
committed
'main': Add an auxiliary variable for readability.
1 parent 0a97e7f commit e0849a8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

highlighters/main/main-highlighter.zsh

+8-3
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,12 @@ _zsh_highlight_main_highlighter_check_path()
10851085
local expanded_path="$REPLY" tmp_path
10861086
integer in_command_position=$2
10871087

1088+
if [[ $zsyh_user_options[autocd] == on ]]; then
1089+
integer autocd=1
1090+
else
1091+
integer autocd=0
1092+
fi
1093+
10881094
if (( in_command_position )); then
10891095
REPLY=arg0
10901096
else
@@ -1107,7 +1113,7 @@ _zsh_highlight_main_highlighter_check_path()
11071113
done
11081114

11091115
if (( in_command_position )); then
1110-
if [[ -x $expanded_path ]] && [[ $zsyh_user_options[autocd] == on || ! -d $expanded_path ]]; then
1116+
if [[ -x $expanded_path ]] && { (( autocd )) || [[ ! -d $expanded_path ]] }; then
11111117
return 0
11121118
fi
11131119
else
@@ -1117,8 +1123,7 @@ _zsh_highlight_main_highlighter_check_path()
11171123
fi
11181124

11191125
# Search the path in CDPATH
1120-
if [[ $expanded_path != /* ]] &&
1121-
{ (( ! in_command_position )) || [[ $zsyh_user_options[autocd] == on ]] }; then
1126+
if [[ $expanded_path != /* ]] && (( autocd || ! in_command_position )); then
11221127
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
11231128
local cdpath_dir
11241129
for cdpath_dir in $cdpath ; do

0 commit comments

Comments
 (0)