diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 7879216245..27da031887 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -249,6 +249,7 @@ _zsh_highlight_call_widget() _zsh_highlight_bind_widgets() { setopt localoptions noksharrays + local prefix=orig-s$SECONDS-r$RANDOM # unique each time, in case we're sourced more than once # Load ZSH module zsh/zleparameter, needed to override user defined widgets. zmodload zsh/zleparameter 2>/dev/null || { @@ -258,7 +259,7 @@ _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)}) + widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank)}) # Always wrap special zle-line-finish widget. This is needed to decide if the # current line ends and special highlighting logic needs to be applied. @@ -283,13 +284,13 @@ _zsh_highlight_bind_widgets() # NO_function_argzero, regardless of the option's setting here. # User defined widget: override and rebind old one with prefix "orig-". - user:*) zle -N orig-$cur_widget ${widgets[$cur_widget]#*:} - eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }" + user:*) zle -N $prefix-$cur_widget ${widgets[$cur_widget]#*:} + eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; # Completion widget: override and rebind old one with prefix "orig-". - completion:*) zle -C orig-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} - eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }" + completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]} + eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }" zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; # Builtin widget: override and make it call the builtin ".widget".