diff --git a/src/bind.zsh b/src/bind.zsh index 3380617..4305a33 100644 --- a/src/bind.zsh +++ b/src/bind.zsh @@ -51,14 +51,16 @@ _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`). - # Preserve the ZLE_KILL | ZLE_YANK flags for builtin widgets. + # Preserve the ZLE_KILL | ZLE_YANK flags for builtin widgets for ZSH >= 5.2 eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() { _zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@ - case ${(q)widget} in - (${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';; - (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';; - (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';; - esac + if [[ ! "${ZSH_VERSION}" < 5.2 ]]; then + case ${(q)widget} in + (${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';; + (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';; + (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';; + esac + fi }" # Create the bound widget diff --git a/src/config.zsh b/src/config.zsh index 9c54585..6b45647 100644 --- a/src/config.zsh +++ b/src/config.zsh @@ -85,6 +85,9 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- yank-pop zle-\* ) + if [[ "${ZSH_VERSION}" < 5.2 ]]; then + ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(yank) + fi } # Pty name for capturing completions for completion suggestion strategy diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index f43ae5b..00fcc86 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -111,6 +111,9 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig- yank-pop zle-\* ) + if [[ "${ZSH_VERSION}" < 5.2 ]]; then + ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(yank) + fi } # Pty name for capturing completions for completion suggestion strategy @@ -207,14 +210,16 @@ _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`). - # Preserve the ZLE_KILL | ZLE_YANK flags for builtin widgets. + # Preserve the ZLE_KILL | ZLE_YANK flags for builtin widgets for ZSH >= 5.2 eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() { _zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@ - case ${(q)widget} in - (${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';; - (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';; - (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';; - esac + if [[ ! "${ZSH_VERSION}" < 5.2 ]]; then + case ${(q)widget} in + (${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';; + (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';; + (${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';; + esac + fi }" # Create the bound widget