noop: Break out a helper function.
This commit is contained in:
parent
1397f1bae1
commit
bdc1449733
@ -80,6 +80,19 @@ _zsh_highlight_main_add_region_highlight() {
|
|||||||
region_highlight+=("$start $end $style")
|
region_highlight+=("$start $end $style")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Wrapper around 'type -w'.
|
||||||
|
#
|
||||||
|
# Takes a single argument and outputs the output of 'type -w $1'.
|
||||||
|
#
|
||||||
|
# NOTE: This runs 'setopt', but that should be safe since it'll only ever be
|
||||||
|
# called inside a $(...) subshell, so the effects will be local.
|
||||||
|
_zsh_highlight_main__type() {
|
||||||
|
if (( $#options_to_set )); then
|
||||||
|
setopt $options_to_set;
|
||||||
|
fi
|
||||||
|
LC_ALL=C builtin type -w -- $1 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# Main syntax highlighting function.
|
# Main syntax highlighting function.
|
||||||
_zsh_highlight_main_highlighter()
|
_zsh_highlight_main_highlighter()
|
||||||
{
|
{
|
||||||
@ -101,7 +114,7 @@ _zsh_highlight_main_highlighter()
|
|||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
|
||||||
typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
|
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
|
local -a options_to_set # used in callees
|
||||||
local buf="$PREBUFFER$BUFFER"
|
local buf="$PREBUFFER$BUFFER"
|
||||||
region_highlight=()
|
region_highlight=()
|
||||||
|
|
||||||
@ -253,12 +266,7 @@ _zsh_highlight_main_highlighter()
|
|||||||
else
|
else
|
||||||
_zsh_highlight_main_highlighter_expand_path $arg
|
_zsh_highlight_main_highlighter_expand_path $arg
|
||||||
local expanded_arg="$REPLY"
|
local expanded_arg="$REPLY"
|
||||||
local res="$(
|
local res="$(_zsh_highlight_main__type ${expanded_arg})"
|
||||||
if (( $#options_to_set )); then
|
|
||||||
setopt $options_to_set;
|
|
||||||
fi
|
|
||||||
LC_ALL=C builtin type -w -- ${expanded_arg} 2>/dev/null
|
|
||||||
)"
|
|
||||||
case $res in
|
case $res in
|
||||||
*': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];;
|
*': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];;
|
||||||
*': suffix alias')
|
*': suffix alias')
|
||||||
|
Loading…
Reference in New Issue
Block a user