Merge part of PR #298
* commit '2f18ba': 'main': use zsh/parameter to resolve alias driver: load zsh/parameter if available
This commit is contained in:
commit
f146651913
@ -103,6 +103,19 @@ _zsh_highlight_main__is_redirection() {
|
||||
[[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]]
|
||||
}
|
||||
|
||||
# Resolve alias.
|
||||
#
|
||||
# Takes a single argument.
|
||||
#
|
||||
# The result will be stored in REPLY.
|
||||
_zsh_highlight_main__resolve_alias() {
|
||||
if zmodload -e zsh/parameter; then
|
||||
REPLY=${aliases[$arg]}
|
||||
else
|
||||
REPLY="${"$(alias -- $arg)"#*=}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main syntax highlighting function.
|
||||
_zsh_highlight_main_highlighter()
|
||||
{
|
||||
@ -354,8 +367,9 @@ _zsh_highlight_main_highlighter()
|
||||
style=unknown-token
|
||||
else
|
||||
style=alias
|
||||
local aliased_command="${"$(alias -- $arg)"#*=}"
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg)
|
||||
_zsh_highlight_main__resolve_alias $arg
|
||||
local alias_target="$REPLY"
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg)
|
||||
fi
|
||||
}
|
||||
;;
|
||||
|
@ -328,5 +328,8 @@ add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
|
||||
echo 'zsh-syntax-highlighting: failed loading add-zsh-hook.' >&2
|
||||
}
|
||||
|
||||
# Load zsh/parameter module if available
|
||||
zmodload zsh/parameter 2>/dev/null || true
|
||||
|
||||
# Initialize the array of active highlighters if needed.
|
||||
[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) || true
|
||||
|
Loading…
Reference in New Issue
Block a user