@@ -83,19 +83,33 @@ _zsh_highlight_main_add_region_highlight() {
83
83
# Main syntax highlighting function.
84
84
_zsh_highlight_main_highlighter ()
85
85
{
86
+ # # Before we even 'emulate -L', we must test a few options that would reset.
86
87
if [[ -o interactive_comments ]]; then
87
88
local interactive_comments= # set to empty
88
89
fi
90
+ if [[ -o path_dirs ]]; then
91
+ integer path_dirs_was_set=1
92
+ else
93
+ integer path_dirs_was_set=0
94
+ fi
89
95
emulate -L zsh
90
96
setopt localoptions extendedglob bareglobqual
97
+
98
+ # # Variable declarations and initializations
91
99
local start_pos=0 end_pos highlight_glob=true arg style
92
100
local in_array_assignment=false # true between 'a=(' and the matching ')'
93
101
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
94
102
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
95
103
typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW
104
+ local -a options_to_set
96
105
local buf=" $PREBUFFER$BUFFER "
97
106
region_highlight=()
98
107
108
+ if (( path_dirs_was_set )) ; then
109
+ options_to_set+=( PATH_DIRS )
110
+ fi
111
+ unset path_dirs_was_set
112
+
99
113
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
100
114
' |' ' ||' ' ;' ' &' ' &&'
101
115
)
@@ -239,7 +253,12 @@ _zsh_highlight_main_highlighter()
239
253
else
240
254
_zsh_highlight_main_highlighter_expand_path $arg
241
255
local expanded_arg=" $REPLY "
242
- local res=" $( LC_ALL=C builtin type -w -- ${expanded_arg} 2> /dev/null) "
256
+ local res=" $(
257
+ if (( $# options_to_set )) ; then
258
+ setopt $options_to_set ;
259
+ fi
260
+ LC_ALL=C builtin type -w -- ${expanded_arg} 2> /dev/null
261
+ ) "
243
262
case $res in
244
263
* ' : reserved' ) style=$ZSH_HIGHLIGHT_STYLES [reserved-word];;
245
264
* ' : suffix alias' )
0 commit comments