1. Removed two additional widgets from the rebinding list: push-input and push-line-or-edit. Both didn't call "_zsh_highlight" function anyhow due to operation principle of these widgets.

2. Adjusted place where zle_highlight is added to region_highlight in order to do it only once (not for all highlithers).

3. Changed indentation in zsh-syntax-highlighting.zsh to make code a bit cleaner and easier to read.
This commit is contained in:
jimmijj 2015-09-04 02:36:22 +02:00
parent ece762e817
commit 3a6ba003d1

View File

@ -62,7 +62,8 @@ _zsh_highlight()
local -a region_highlight_copy
# Select which highlighters in ZSH_HIGHLIGHT_HIGHLIGHTERS need to be invoked.
local highlighter; for highlighter in $ZSH_HIGHLIGHT_HIGHLIGHTERS; do
local highlighter
for highlighter in $ZSH_HIGHLIGHT_HIGHLIGHTERS; do
# eval cache place for current highlighter and prepare it
cache_place="_zsh_highlight_${highlighter}_highlighter_cache"
@ -90,9 +91,10 @@ _zsh_highlight()
# Use value form cache if any cached
eval "region_highlight+=(\"\${${cache_place}[@]}\")"
done
# Bring back region higlighting from zle_highlight array (was overwriten by region_highlight)
((REGION_ACTIVE)) && region_highlight+=("$((CURSOR < MARK ? CURSOR : MARK)) $((CURSOR > MARK ? CURSOR : MARK)) ${${(M)zle_highlight[@]:#region*}#region:}")
done
} always {
_ZSH_HIGHLIGHT_PRIOR_BUFFER=$BUFFER
@ -142,7 +144,7 @@ _zsh_highlight_bind_widgets()
# Override ZLE widgets to make them invoke _zsh_highlight.
local cur_widget
for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|beep|auto-*|*-argument|argument-base|clear-screen|describe-key-briefly|kill-buffer|overwrite-mode|reset-prompt|set-local-history|split-undo|undefined-key|what-cursor-position|where-is)}; do
for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|beep|auto-*|*-argument|argument-base|clear-screen|describe-key-briefly|kill-buffer|overwrite-mode|push-input|push-line-or-edit|reset-prompt|set-local-history|split-undo|undefined-key|what-cursor-position|where-is)}; do
case $widgets[$cur_widget] in
# Already rebound event: do nothing.
@ -220,7 +222,7 @@ _zsh_highlight_preexec_hook()
autoload -U add-zsh-hook
add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
echo 'zsh-syntax-highlighting: failed loading add-zsh-hook.' >&2
}
}
# Initialize the array of active highlighters if needed.
[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) || true