Skip to content

Commit ae02016

Browse files
committed
'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.
1 parent 750aebc commit ae02016

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

zsh-syntax-highlighting.zsh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@ _zsh_highlight_bind_widgets()
235235
}
236236

237237
# Override ZLE widgets to make them invoke _zsh_highlight.
238+
local -U widgets_to_bind
239+
widgets_to_bind=(${${(f)"$(builtin zle -la)"}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)})
238240
local cur_widget
239-
for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do
241+
for cur_widget in $widgets_to_bind; do
240242
case $widgets[$cur_widget] in
241243

242244
# Already rebound event: do nothing.
@@ -262,6 +264,10 @@ _zsh_highlight_bind_widgets()
262264
builtin) eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }"
263265
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
264266

267+
# Special zle-* hook that is currently not bound at all: Bind to z-sy-h driectly.
268+
'') eval "_zsh_highlight_widget_${(q)cur_widget}() { :; _zsh_highlight }"
269+
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
270+
265271
# Default: unhandled case.
266272
*) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
267273
esac

0 commit comments

Comments
 (0)