'driver': Widget binding: Support binding unbound zle hooks

If a special zle-* hook is currently unbound, there is no entry
in $widgets. Support that case by adding a new case branch.
This commit is contained in:
m0viefreak 2016-03-29 21:50:46 +02:00
parent b9112aec79
commit f9c95b2ef3

View File

@ -235,8 +235,10 @@ _zsh_highlight_bind_widgets()
} }
# Override ZLE widgets to make them invoke _zsh_highlight. # Override ZLE widgets to make them invoke _zsh_highlight.
local -U widgets_to_bind
widgets_to_bind=(${${(k)widgets}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)})
local cur_widget local cur_widget
for cur_widget in ${${(k)widgets}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do for cur_widget in $widgets_to_bind; do
case $widgets[$cur_widget] in case $widgets[$cur_widget] in
# Already rebound event: do nothing. # Already rebound event: do nothing.
@ -262,6 +264,10 @@ _zsh_highlight_bind_widgets()
builtin) eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" builtin) eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }"
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
# Special zle-* hook that is currently not bound at all: Bind to z-sy-h driectly.
'') eval "_zsh_highlight_widget_${(q)cur_widget}() { :; _zsh_highlight }"
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
# Default: unhandled case. # Default: unhandled case.
*) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
esac esac