mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2026-11-11 11:01:51 -05:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
141f497d17 |
@@ -1,10 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## v0.5.1
|
|
||||||
- Speed up widget rebinding (#413)
|
|
||||||
- Clean up global variable creations (#403)
|
|
||||||
- Respect user's set options when running original widget (#402)
|
|
||||||
|
|
||||||
## v0.5.0
|
## v0.5.0
|
||||||
- Don't overwrite config with default values (#335)
|
- Don't overwrite config with default values (#335)
|
||||||
- Support fallback strategies by supplying array to suggestion config var
|
- Support fallback strategies by supplying array to suggestion config var
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
describe 'multiple words killed with `backward-kill-word`' do
|
||||||
|
before do
|
||||||
|
session.
|
||||||
|
send_string('echo first second').
|
||||||
|
send_keys('C-w').
|
||||||
|
send_keys('C-w')
|
||||||
|
wait_for { session.content }.to eq('echo')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'can be yanked back with `yank`' do
|
||||||
|
session.send_keys('C-y')
|
||||||
|
wait_for { session.content }.to eq('echo first second')
|
||||||
|
end
|
||||||
|
end
|
||||||
+21
-8
@@ -4,8 +4,21 @@
|
|||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
||||||
_zsh_autosuggest_incr_bind_count() {
|
_zsh_autosuggest_incr_bind_count() {
|
||||||
typeset -gi bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]+1))
|
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
||||||
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count
|
((_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
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
||||||
@@ -21,30 +34,30 @@ _zsh_autosuggest_bind_widget() {
|
|||||||
# Save a reference to the original widget
|
# Save a reference to the original widget
|
||||||
case $widgets[$widget] in
|
case $widgets[$widget] in
|
||||||
# Already bound
|
# Already bound
|
||||||
user:_zsh_autosuggest_(bound|orig)_*)
|
user:_zsh_autosuggest_(bound|orig)_*);;
|
||||||
bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$widget]))
|
|
||||||
;;
|
|
||||||
|
|
||||||
# User-defined widget
|
# User-defined widget
|
||||||
user:*)
|
user:*)
|
||||||
_zsh_autosuggest_incr_bind_count $widget
|
_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
|
# Built-in widget
|
||||||
builtin)
|
builtin)
|
||||||
_zsh_autosuggest_incr_bind_count $widget
|
_zsh_autosuggest_incr_bind_count $widget
|
||||||
eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)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 widget
|
||||||
completion:*)
|
completion:*)
|
||||||
_zsh_autosuggest_incr_bind_count $widget
|
_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
|
esac
|
||||||
|
|
||||||
|
_zsh_autosuggest_get_bind_count $widget
|
||||||
|
|
||||||
# Pass the original widget's name explicitly into the autosuggest
|
# Pass the original widget's name explicitly into the autosuggest
|
||||||
# function. Use this passed in widget name to call the original
|
# function. Use this passed in widget name to call the original
|
||||||
# widget instead of relying on the $WIDGET variable being set
|
# widget instead of relying on the $WIDGET variable being set
|
||||||
|
|||||||
+21
-8
@@ -165,8 +165,21 @@ _zsh_autosuggest_feature_detect_zpty_returns_fd() {
|
|||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
||||||
_zsh_autosuggest_incr_bind_count() {
|
_zsh_autosuggest_incr_bind_count() {
|
||||||
typeset -gi bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]+1))
|
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
||||||
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count
|
((_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
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
||||||
@@ -182,30 +195,30 @@ _zsh_autosuggest_bind_widget() {
|
|||||||
# Save a reference to the original widget
|
# Save a reference to the original widget
|
||||||
case $widgets[$widget] in
|
case $widgets[$widget] in
|
||||||
# Already bound
|
# Already bound
|
||||||
user:_zsh_autosuggest_(bound|orig)_*)
|
user:_zsh_autosuggest_(bound|orig)_*);;
|
||||||
bind_count=$((_ZSH_AUTOSUGGEST_BIND_COUNTS[$widget]))
|
|
||||||
;;
|
|
||||||
|
|
||||||
# User-defined widget
|
# User-defined widget
|
||||||
user:*)
|
user:*)
|
||||||
_zsh_autosuggest_incr_bind_count $widget
|
_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
|
# Built-in widget
|
||||||
builtin)
|
builtin)
|
||||||
_zsh_autosuggest_incr_bind_count $widget
|
_zsh_autosuggest_incr_bind_count $widget
|
||||||
eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)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 widget
|
||||||
completion:*)
|
completion:*)
|
||||||
_zsh_autosuggest_incr_bind_count $widget
|
_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
|
esac
|
||||||
|
|
||||||
|
_zsh_autosuggest_get_bind_count $widget
|
||||||
|
|
||||||
# Pass the original widget's name explicitly into the autosuggest
|
# Pass the original widget's name explicitly into the autosuggest
|
||||||
# function. Use this passed in widget name to call the original
|
# function. Use this passed in widget name to call the original
|
||||||
# widget instead of relying on the $WIDGET variable being set
|
# widget instead of relying on the $WIDGET variable being set
|
||||||
|
|||||||
Reference in New Issue
Block a user