From 945c660856758b98ad70d06d5ec306a59c3045a7 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Mon, 25 Apr 2016 14:23:30 -0600 Subject: [PATCH] Fix #152 by escaping widget names inside evals Solves problems when dealing with widget names with irregular characters such as those that come from `opp.zsh`. --- src/bind.zsh | 8 ++++---- zsh-autosuggestions.zsh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bind.zsh b/src/bind.zsh index b1e68f1..008848a 100644 --- a/src/bind.zsh +++ b/src/bind.zsh @@ -21,13 +21,13 @@ _zsh_autosuggest_bind_widget() { # Built-in widget builtin) - eval "_zsh_autosuggest_orig_$widget() { zle .$widget }" + eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }" zle -N $prefix$widget _zsh_autosuggest_orig_$widget ;; # Completion widget completion:*) - eval "zle -C $prefix$widget ${${widgets[$widget]#*:}/:/ }" + eval "zle -C $prefix${(q)widget} ${${widgets[$widget]#*:}/:/ }" ;; esac @@ -37,8 +37,8 @@ _zsh_autosuggest_bind_widget() { # correctly. $WIDGET cannot be trusted because other plugins call # zle without the `-w` flag (e.g. `zle self-insert` instead of # `zle self-insert -w`). - eval "_zsh_autosuggest_bound_$widget() { - _zsh_autosuggest_widget_$autosuggest_action $prefix$widget \$@ + eval "_zsh_autosuggest_bound_${(q)widget}() { + _zsh_autosuggest_widget_$autosuggest_action $prefix${(q)widget} \$@ }" # Create the bound widget diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index ec1d53f..1e8004f 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -132,13 +132,13 @@ _zsh_autosuggest_bind_widget() { # Built-in widget builtin) - eval "_zsh_autosuggest_orig_$widget() { zle .$widget }" + eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }" zle -N $prefix$widget _zsh_autosuggest_orig_$widget ;; # Completion widget completion:*) - eval "zle -C $prefix$widget ${${widgets[$widget]#*:}/:/ }" + eval "zle -C $prefix${(q)widget} ${${widgets[$widget]#*:}/:/ }" ;; esac @@ -148,8 +148,8 @@ _zsh_autosuggest_bind_widget() { # correctly. $WIDGET cannot be trusted because other plugins call # zle without the `-w` flag (e.g. `zle self-insert` instead of # `zle self-insert -w`). - eval "_zsh_autosuggest_bound_$widget() { - _zsh_autosuggest_widget_$autosuggest_action $prefix$widget \$@ + eval "_zsh_autosuggest_bound_${(q)widget}() { + _zsh_autosuggest_widget_$autosuggest_action $prefix${(q)widget} \$@ }" # Create the bound widget