mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-27 22:43:41 +08:00
Merge pull request #413 from zsh-users/features/faster-prompts
Features/faster prompts
This commit is contained in:
commit
0b13f663da
29
src/bind.zsh
29
src/bind.zsh
|
@ -4,21 +4,8 @@
|
|||
#--------------------------------------------------------------------#
|
||||
|
||||
_zsh_autosuggest_incr_bind_count() {
|
||||
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
||||
((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]++))
|
||||
else
|
||||
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=1
|
||||
fi
|
||||
|
||||
typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
|
||||
}
|
||||
|
||||
_zsh_autosuggest_get_bind_count() {
|
||||
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
||||
typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
|
||||
else
|
||||
typeset -gi bind_count=0
|
||||
fi
|
||||
typeset -gi bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]+1))
|
||||
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count
|
||||
}
|
||||
|
||||
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
||||
|
@ -34,30 +21,30 @@ _zsh_autosuggest_bind_widget() {
|
|||
# Save a reference to the original widget
|
||||
case $widgets[$widget] in
|
||||
# Already bound
|
||||
user:_zsh_autosuggest_(bound|orig)_*);;
|
||||
user:_zsh_autosuggest_(bound|orig)_*)
|
||||
bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$widget]))
|
||||
;;
|
||||
|
||||
# User-defined widget
|
||||
user:*)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
zle -N $prefix${bind_count}-$widget ${widgets[$widget]#*:}
|
||||
zle -N $prefix$bind_count-$widget ${widgets[$widget]#*:}
|
||||
;;
|
||||
|
||||
# Built-in widget
|
||||
builtin)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }"
|
||||
zle -N $prefix${bind_count}-$widget _zsh_autosuggest_orig_$widget
|
||||
zle -N $prefix$bind_count-$widget _zsh_autosuggest_orig_$widget
|
||||
;;
|
||||
|
||||
# Completion widget
|
||||
completion:*)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
eval "zle -C $prefix${bind_count}-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}"
|
||||
eval "zle -C $prefix$bind_count-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}"
|
||||
;;
|
||||
esac
|
||||
|
||||
_zsh_autosuggest_get_bind_count $widget
|
||||
|
||||
# Pass the original widget's name explicitly into the autosuggest
|
||||
# function. Use this passed in widget name to call the original
|
||||
# widget instead of relying on the $WIDGET variable being set
|
||||
|
|
|
@ -165,21 +165,8 @@ _zsh_autosuggest_feature_detect_zpty_returns_fd() {
|
|||
#--------------------------------------------------------------------#
|
||||
|
||||
_zsh_autosuggest_incr_bind_count() {
|
||||
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
||||
((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]++))
|
||||
else
|
||||
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=1
|
||||
fi
|
||||
|
||||
typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
|
||||
}
|
||||
|
||||
_zsh_autosuggest_get_bind_count() {
|
||||
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
||||
typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
|
||||
else
|
||||
typeset -gi bind_count=0
|
||||
fi
|
||||
typeset -gi bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]+1))
|
||||
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count
|
||||
}
|
||||
|
||||
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
||||
|
@ -195,30 +182,30 @@ _zsh_autosuggest_bind_widget() {
|
|||
# Save a reference to the original widget
|
||||
case $widgets[$widget] in
|
||||
# Already bound
|
||||
user:_zsh_autosuggest_(bound|orig)_*);;
|
||||
user:_zsh_autosuggest_(bound|orig)_*)
|
||||
bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$widget]))
|
||||
;;
|
||||
|
||||
# User-defined widget
|
||||
user:*)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
zle -N $prefix${bind_count}-$widget ${widgets[$widget]#*:}
|
||||
zle -N $prefix$bind_count-$widget ${widgets[$widget]#*:}
|
||||
;;
|
||||
|
||||
# Built-in widget
|
||||
builtin)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }"
|
||||
zle -N $prefix${bind_count}-$widget _zsh_autosuggest_orig_$widget
|
||||
zle -N $prefix$bind_count-$widget _zsh_autosuggest_orig_$widget
|
||||
;;
|
||||
|
||||
# Completion widget
|
||||
completion:*)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
eval "zle -C $prefix${bind_count}-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}"
|
||||
eval "zle -C $prefix$bind_count-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}"
|
||||
;;
|
||||
esac
|
||||
|
||||
_zsh_autosuggest_get_bind_count $widget
|
||||
|
||||
# Pass the original widget's name explicitly into the autosuggest
|
||||
# function. Use this passed in widget name to call the original
|
||||
# widget instead of relying on the $WIDGET variable being set
|
||||
|
|
Loading…
Reference in New Issue
Block a user