mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Added ZSH version check
This commit is contained in:
parent
6e15a2d3de
commit
36f37f50d1
3 changed files with 22 additions and 12 deletions
14
src/bind.zsh
14
src/bind.zsh
|
@ -51,14 +51,16 @@ _zsh_autosuggest_bind_widget() {
|
||||||
# correctly. $WIDGET cannot be trusted because other plugins call
|
# correctly. $WIDGET cannot be trusted because other plugins call
|
||||||
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
||||||
# `zle self-insert -w`).
|
# `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}() {
|
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
|
||||||
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
||||||
case ${(q)widget} in
|
if [[ ! "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';;
|
case ${(q)widget} in
|
||||||
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';;
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';;
|
||||||
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';;
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';;
|
||||||
esac
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
|
|
|
@ -85,6 +85,9 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
yank-pop
|
yank-pop
|
||||||
zle-\*
|
zle-\*
|
||||||
)
|
)
|
||||||
|
if [[ "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
|
ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(yank)
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pty name for capturing completions for completion suggestion strategy
|
# Pty name for capturing completions for completion suggestion strategy
|
||||||
|
|
|
@ -111,6 +111,9 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
yank-pop
|
yank-pop
|
||||||
zle-\*
|
zle-\*
|
||||||
)
|
)
|
||||||
|
if [[ "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
|
ZSH_AUTOSUGGEST_IGNORE_WIDGETS+=(yank)
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pty name for capturing completions for completion suggestion strategy
|
# 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
|
# correctly. $WIDGET cannot be trusted because other plugins call
|
||||||
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
||||||
# `zle self-insert -w`).
|
# `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}() {
|
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
|
||||||
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
||||||
case ${(q)widget} in
|
if [[ ! "${ZSH_VERSION}" < 5.2 ]]; then
|
||||||
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';;
|
case ${(q)widget} in
|
||||||
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';;
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS}) zle -f 'kill';;
|
||||||
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';;
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS}) zle -f 'yank';;
|
||||||
esac
|
(${(j:|:)ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS}) zle -f 'yankbefore';;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
|
|
Loading…
Reference in a new issue