mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-02-13 10:05:31 +08:00
'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:
parent
b9112aec79
commit
f9c95b2ef3
@ -235,8 +235,10 @@ _zsh_highlight_bind_widgets()
|
||||
}
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
# 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} -- \"\$@\" }"
|
||||
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.
|
||||
*) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user