'main': Unify $ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS and $precommand_options.
This commit is contained in:
parent
31ceaed4f4
commit
f7ac43cd49
|
@ -243,7 +243,6 @@ _zsh_highlight_highlighter_main_paint()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
|
||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW
|
typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW
|
||||||
local -a options_to_set reply # used in callees
|
local -a options_to_set reply # used in callees
|
||||||
local REPLY
|
local REPLY
|
||||||
|
@ -265,6 +264,11 @@ _zsh_highlight_highlighter_main_paint()
|
||||||
'nice' n # as of current POSIX spec
|
'nice' n # as of current POSIX spec
|
||||||
'sudo' Cgprtu:AEHKPSVbhiklnsv # as of sudo 1.8.21p2
|
'sudo' Cgprtu:AEHKPSVbhiklnsv # as of sudo 1.8.21p2
|
||||||
'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
|
'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
|
||||||
|
'builtin' '' # as of zsh 5.4.2
|
||||||
|
'exec' a:cl # as of zsh 5.4.2
|
||||||
|
'nocorrect' '' # as of zsh 5.4.2
|
||||||
|
'noglob' '' # as of zsh 5.4.2
|
||||||
|
'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
|
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
|
||||||
|
@ -284,10 +288,6 @@ _zsh_highlight_highlighter_main_paint()
|
||||||
# ### 'case' syntax, but followed by a pattern, not by a command
|
# ### 'case' syntax, but followed by a pattern, not by a command
|
||||||
# ';;' ';&' ';|'
|
# ';;' ';&' ';|'
|
||||||
)
|
)
|
||||||
ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=(
|
|
||||||
'builtin' 'exec' 'nocorrect' 'noglob'
|
|
||||||
'pkexec' # immune to #121 because it's usually not passed --option flags
|
|
||||||
)
|
|
||||||
|
|
||||||
# Tokens that, at (naively-determined) "command position", are followed by
|
# Tokens that, at (naively-determined) "command position", are followed by
|
||||||
# a de jure command position. All of these are reserved words.
|
# a de jure command position. All of these are reserved words.
|
||||||
|
@ -614,8 +614,6 @@ _zsh_highlight_main_highlighter_highlight_list()
|
||||||
next_word=${next_word//:regular:/}
|
next_word=${next_word//:regular:/}
|
||||||
next_word+=':sudo_opt:'
|
next_word+=':sudo_opt:'
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
|
|
||||||
style=precommand
|
|
||||||
else
|
else
|
||||||
case $res in
|
case $res in
|
||||||
reserved) # reserved word
|
reserved) # reserved word
|
||||||
|
@ -694,7 +692,9 @@ _zsh_highlight_main_highlighter_highlight_list()
|
||||||
else
|
else
|
||||||
# The common case.
|
# The common case.
|
||||||
style=alias
|
style=alias
|
||||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg_raw"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg_raw)
|
if (( ${+precommand_options[(re)"$arg"]} )) && (( ! ${+precommand_options[(re)"$arg_raw"]} )); then
|
||||||
|
precommand_options[$arg_raw]=$precommand_options[$arg]
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
|
@ -844,8 +844,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
||||||
highlight_glob=true
|
highlight_glob=true
|
||||||
fi
|
fi
|
||||||
elif
|
elif
|
||||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:'* ]] ||
|
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:'* ]]; then
|
||||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:'* ]]; then
|
|
||||||
next_word=':start:'
|
next_word=':start:'
|
||||||
elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then
|
elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then
|
||||||
# skip the repeat-count word
|
# skip the repeat-count word
|
||||||
|
|
Loading…
Reference in New Issue
Block a user