mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Preserve ZLE_KILL and ZLE_YANK flags
This commit is contained in:
parent
a411ef3e09
commit
6e15a2d3de
3 changed files with 66 additions and 2 deletions
|
@ -51,8 +51,14 @@ _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.
|
||||||
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
|
||||||
|
(${(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
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
|
|
|
@ -82,7 +82,6 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
run-help
|
run-help
|
||||||
set-local-history
|
set-local-history
|
||||||
which-command
|
which-command
|
||||||
yank
|
|
||||||
yank-pop
|
yank-pop
|
||||||
zle-\*
|
zle-\*
|
||||||
)
|
)
|
||||||
|
@ -91,3 +90,30 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
# Pty name for capturing completions for completion suggestion strategy
|
# Pty name for capturing completions for completion suggestion strategy
|
||||||
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
||||||
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_KILL flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS=(
|
||||||
|
kill-\*
|
||||||
|
backward-kill-\*
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANK flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS=(
|
||||||
|
bracketed-paste
|
||||||
|
vi-put-after
|
||||||
|
yank
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANKBEFORE flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS=(
|
||||||
|
vi-put-before
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -108,7 +108,6 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
run-help
|
run-help
|
||||||
set-local-history
|
set-local-history
|
||||||
which-command
|
which-command
|
||||||
yank
|
|
||||||
yank-pop
|
yank-pop
|
||||||
zle-\*
|
zle-\*
|
||||||
)
|
)
|
||||||
|
@ -118,6 +117,33 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||||
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
(( ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
|
||||||
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
typeset -g ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME=zsh_autosuggest_completion_pty
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_KILL flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_KILL_WIDGETS=(
|
||||||
|
kill-\*
|
||||||
|
backward-kill-\*
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANK flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANK_WIDGETS=(
|
||||||
|
bracketed-paste
|
||||||
|
vi-put-after
|
||||||
|
yank
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Widgets that should preserve ZLE_YANKBEFORE flag
|
||||||
|
(( ! ${+ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS} )) && {
|
||||||
|
typeset -ga ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS
|
||||||
|
ZSH_AUTOSUGGEST_ZLE_YANKBEFORE_WIDGETS=(
|
||||||
|
vi-put-before
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
# Utility Functions #
|
# Utility Functions #
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
@ -181,8 +207,14 @@ _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.
|
||||||
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
|
||||||
|
(${(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
|
||||||
}"
|
}"
|
||||||
|
|
||||||
# Create the bound widget
|
# Create the bound widget
|
||||||
|
|
Loading…
Reference in a new issue