'main': Enable fallback to the 'arg0' style.
This commit is contained in:
@@ -32,17 +32,11 @@
|
||||
: ${ZSH_HIGHLIGHT_STYLES[default]:=none}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[alias]:=fg=green}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[builtin]:=fg=green}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[function]:=fg=green}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[command]:=fg=green}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[hashed-command]:=fg=green}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[path_prefix]:=underline}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
|
||||
: ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue}
|
||||
@@ -72,6 +66,33 @@ _zsh_highlight_main_add_region_highlight() {
|
||||
integer start=$1 end=$2
|
||||
shift 2
|
||||
|
||||
if (( $+argv[2] )); then
|
||||
# Caller specified inheritance explicitly.
|
||||
else
|
||||
# Automate inheritance.
|
||||
typeset -A fallback_of; fallback_of=(
|
||||
alias arg0
|
||||
suffix-alias arg0
|
||||
builtin arg0
|
||||
function arg0
|
||||
command arg0
|
||||
precommand arg0
|
||||
hashed-command arg0
|
||||
|
||||
path_prefix path
|
||||
# The path separator fallback won't ever be used, due to the optimisation
|
||||
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
||||
path_pathseparator path
|
||||
path_prefix_pathseparator path_prefix
|
||||
)
|
||||
local needle=$1 value
|
||||
while [[ -n ${value::=$fallback_of[$needle]} ]]; do
|
||||
unset "fallback_of[$needle]" # paranoia against infinite loops
|
||||
argv+=($value)
|
||||
needle=$value
|
||||
done
|
||||
fi
|
||||
|
||||
# The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is
|
||||
# relative to $BUFFER.
|
||||
(( start -= $#PREBUFFER ))
|
||||
|
||||
Reference in New Issue
Block a user