main: Save user options in a single variable
This commit is contained in:
parent
749b30221d
commit
2a50614579
@ -194,25 +194,8 @@ _zsh_highlight_main__stack_pop() {
|
||||
# Main syntax highlighting function.
|
||||
_zsh_highlight_highlighter_main_paint()
|
||||
{
|
||||
## Before we even 'emulate -L', we must test a few options that would reset.
|
||||
if [[ -o interactive_comments ]]; then
|
||||
local interactive_comments= # set to empty
|
||||
fi
|
||||
if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then
|
||||
local right_brace_is_recognised_everywhere=false
|
||||
else
|
||||
local right_brace_is_recognised_everywhere=true
|
||||
fi
|
||||
if [[ -o path_dirs ]]; then
|
||||
integer path_dirs_was_set=1
|
||||
else
|
||||
integer path_dirs_was_set=0
|
||||
fi
|
||||
if [[ -o multi_func_def ]]; then
|
||||
integer multi_func_def=1
|
||||
else
|
||||
integer multi_func_def=0
|
||||
fi
|
||||
# Before we even 'emulate -L', save the user's options
|
||||
local -A useroptions=("${(@kv)options}")
|
||||
emulate -L zsh
|
||||
setopt localoptions extendedglob bareglobqual
|
||||
|
||||
@ -245,10 +228,15 @@ _zsh_highlight_highlighter_main_paint()
|
||||
# ":" for 'then'
|
||||
local braces_stack
|
||||
|
||||
if (( path_dirs_was_set )); then
|
||||
if [[ $useroptions[ignorebraces] == on || ${useroptions[ignoreclosebraces]:-off} == on ]]; then
|
||||
local right_brace_is_recognised_everywhere=false
|
||||
else
|
||||
local right_brace_is_recognised_everywhere=true
|
||||
fi
|
||||
|
||||
if [[ $useroptions[pathdirs] == on ]]; then
|
||||
options_to_set+=( PATH_DIRS )
|
||||
fi
|
||||
unset path_dirs_was_set
|
||||
|
||||
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
||||
'|' '||' ';' '&' '&&'
|
||||
@ -322,8 +310,13 @@ _zsh_highlight_highlighter_main_paint()
|
||||
integer in_redirection
|
||||
# Processing buffer
|
||||
local proc_buf="$buf"
|
||||
for arg in ${interactive_comments-${(z)buf}} \
|
||||
${interactive_comments+${(zZ+c+)buf}}; do
|
||||
local -a args
|
||||
if [[ $useroptions[interactivecomments] == on ]]; then
|
||||
args=(${(zZ+c+)buf})
|
||||
else
|
||||
args=(${(z)buf})
|
||||
fi
|
||||
for arg in $args; do
|
||||
# Initialize $next_word.
|
||||
if (( in_redirection )); then
|
||||
(( --in_redirection ))
|
||||
@ -412,7 +405,7 @@ _zsh_highlight_highlighter_main_paint()
|
||||
# Handle the INTERACTIVE_COMMENTS option.
|
||||
#
|
||||
# We use the (Z+c+) flag so the entire comment is presented as one token in $arg.
|
||||
if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then
|
||||
if [[ $useroptions[interactivecomments] == on && $arg[1] == $histchars[3] ]]; then
|
||||
if [[ $this_word == *(':regular:'|':start:')* ]]; then
|
||||
style=comment
|
||||
else
|
||||
@ -648,7 +641,7 @@ _zsh_highlight_highlighter_main_paint()
|
||||
_zsh_highlight_main__stack_pop 'R' style=reserved-word
|
||||
fi;;
|
||||
$'\x28\x29') # possibly a function definition
|
||||
if (( multi_func_def )) || false # TODO: or if the previous word was a command word
|
||||
if [[ $useroptions[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
|
||||
then
|
||||
next_word+=':start:'
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user