@@ -194,25 +194,8 @@ _zsh_highlight_main__stack_pop() {
194
194
# Main syntax highlighting function.
195
195
_zsh_highlight_highlighter_main_paint ()
196
196
{
197
- # # Before we even 'emulate -L', we must test a few options that would reset.
198
- if [[ -o interactive_comments ]]; then
199
- local interactive_comments= # set to empty
200
- fi
201
- if [[ -o ignore_braces ]] || eval ' [[ -o ignore_close_braces ]] 2>/dev/null' ; then
202
- local right_brace_is_recognised_everywhere=false
203
- else
204
- local right_brace_is_recognised_everywhere=true
205
- fi
206
- if [[ -o path_dirs ]]; then
207
- integer path_dirs_was_set=1
208
- else
209
- integer path_dirs_was_set=0
210
- fi
211
- if [[ -o multi_func_def ]]; then
212
- integer multi_func_def=1
213
- else
214
- integer multi_func_def=0
215
- fi
197
+ # Before we even 'emulate -L', save the user's options
198
+ local -A useroptions=(" ${(@ kv)options} " )
216
199
emulate -L zsh
217
200
setopt localoptions extendedglob bareglobqual
218
201
@@ -245,10 +228,15 @@ _zsh_highlight_highlighter_main_paint()
245
228
# ":" for 'then'
246
229
local braces_stack
247
230
248
- if (( path_dirs_was_set )) ; then
231
+ if [[ $useroptions [ignorebraces] == on || ${useroptions[ignoreclosebraces]:- off} == on ]]; then
232
+ local right_brace_is_recognised_everywhere=false
233
+ else
234
+ local right_brace_is_recognised_everywhere=true
235
+ fi
236
+
237
+ if [[ $useroptions [pathdirs] == on ]]; then
249
238
options_to_set+=( PATH_DIRS )
250
239
fi
251
- unset path_dirs_was_set
252
240
253
241
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
254
242
' |' ' ||' ' ;' ' &' ' &&'
@@ -322,8 +310,13 @@ _zsh_highlight_highlighter_main_paint()
322
310
integer in_redirection
323
311
# Processing buffer
324
312
local proc_buf=" $buf "
325
- for arg in ${interactive_comments-${(z)buf} } \
326
- ${interactive_comments+${(zZ+c+)buf} } ; do
313
+ local -a args
314
+ if [[ $useroptions [interactivecomments] == on ]]; then
315
+ args=(${(zZ+c+)buf} )
316
+ else
317
+ args=(${(z)buf} )
318
+ fi
319
+ for arg in $args ; do
327
320
# Initialize $next_word.
328
321
if (( in_redirection )) ; then
329
322
(( -- in_redirection ))
@@ -412,7 +405,7 @@ _zsh_highlight_highlighter_main_paint()
412
405
# Handle the INTERACTIVE_COMMENTS option.
413
406
#
414
407
# We use the (Z+c+) flag so the entire comment is presented as one token in $arg.
415
- if [[ -n ${interactive_comments+ ' set ' } && $arg [1] == $histchars [3] ]]; then
408
+ if [[ $useroptions [interactivecomments] == on && $arg [1] == $histchars [3] ]]; then
416
409
if [[ $this_word == * (' :regular:' | ' :start:' )* ]]; then
417
410
style=comment
418
411
else
@@ -648,7 +641,7 @@ _zsh_highlight_highlighter_main_paint()
648
641
_zsh_highlight_main__stack_pop ' R' style=reserved-word
649
642
fi ;;
650
643
$' \x28\x29 ' ) # possibly a function definition
651
- if (( multi_func_def )) || false # TODO: or if the previous word was a command word
644
+ if [[ $useroptions [multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
652
645
then
653
646
next_word+=' :start:'
654
647
fi
0 commit comments