Skip to content

Commit b7b20d5

Browse files
m0viedanielshahaf
authored andcommitted
driver: Widget binding: Support binding incomplete/nonexistent widgets
1 parent e6fb61c commit b7b20d5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

zsh-syntax-highlighting.zsh

+7-1
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ _zsh_highlight_bind_widgets()
250250
}
251251

252252
# Override ZLE widgets to make them invoke _zsh_highlight.
253+
local -U widgets_to_bind
254+
widgets_to_bind=(${${(k)widgets}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)})
253255
local cur_widget
254-
for cur_widget in ${${(k)widgets}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do
256+
for cur_widget in $widgets_to_bind; do
255257
case $widgets[$cur_widget] in
256258

257259
# Already rebound event: do nothing.
@@ -277,6 +279,10 @@ _zsh_highlight_bind_widgets()
277279
builtin) eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }"
278280
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
279281

282+
# Incomplete or nonexistent widget: Bind to z-sy-h driectly.
283+
'') _zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight }
284+
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
285+
280286
# Default: unhandled case.
281287
*) print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" ;;
282288
esac

0 commit comments

Comments
 (0)