widget binding: Properly escape widget names at definition.

Re-Fixes zsh-users/zsh-syntax-highlighting#278.
This commit is contained in:
Daniel Shahaf 2016-03-18 13:58:55 +00:00
parent 47a664447c
commit 6a634fac9f

View File

@ -224,19 +224,22 @@ _zsh_highlight_bind_widgets()
# The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function
# definition time is used. # definition time is used.
#
# We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with
# NO_function_argzero, regardless of the option's setting here.
# User defined widget: override and rebind old one with prefix "orig-". # User defined widget: override and rebind old one with prefix "orig-".
user:*) zle -N orig-$cur_widget ${widgets[$cur_widget]#*:} user:*) zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}
eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- \"\$@\" }" eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }"
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
# Completion widget: override and rebind old one with prefix "orig-". # Completion widget: override and rebind old one with prefix "orig-".
completion:*) zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ } completion:*) zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }
eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- \"\$@\" }" eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget orig-${(q)cur_widget} -- \"\$@\" }"
zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; zle -N $cur_widget _zsh_highlight_widget_$cur_widget;;
# Builtin widget: override and make it call the builtin ".widget". # Builtin widget: override and make it call the builtin ".widget".
builtin) eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget .$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;;
# Default: unhandled case. # Default: unhandled case.