mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Fix #141: Disable suggestions for widgets called from widgets
This commit is contained in:
parent
62cdba4e0f
commit
9fb9675306
6 changed files with 34 additions and 28 deletions
|
@ -22,6 +22,8 @@ _zsh_autosuggest_modify() {
|
|||
_zsh_autosuggest_invoke_original_widget $@
|
||||
retval=$?
|
||||
|
||||
# Only fetch suggestions at the first level of widget recursion
|
||||
if [ -z "${funcstack[(rn:2:)_zsh_autosuggest_widget_*]}" ]; then
|
||||
# Get a new suggestion if the buffer is not empty after modification
|
||||
local suggestion
|
||||
if [ $#BUFFER -gt 0 ]; then
|
||||
|
@ -34,6 +36,7 @@ _zsh_autosuggest_modify() {
|
|||
else
|
||||
unset POSTDISPLAY
|
||||
fi
|
||||
fi
|
||||
|
||||
return $retval
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ testCursorAtEnd() {
|
|||
|
||||
stub _zsh_autosuggest_invoke_original_widget
|
||||
|
||||
_zsh_autosuggest_accept 'original-widget'
|
||||
_zsh_autosuggest_widget_accept 'original-widget'
|
||||
|
||||
assertTrue \
|
||||
'original widget not invoked' \
|
||||
|
@ -48,7 +48,7 @@ testCursorNotAtEnd() {
|
|||
|
||||
stub _zsh_autosuggest_invoke_original_widget
|
||||
|
||||
_zsh_autosuggest_accept 'original-widget'
|
||||
_zsh_autosuggest_widget_accept 'original-widget'
|
||||
|
||||
assertTrue \
|
||||
'original widget not invoked' \
|
||||
|
@ -73,7 +73,7 @@ testViCursorAtEnd() {
|
|||
|
||||
stub _zsh_autosuggest_invoke_original_widget
|
||||
|
||||
_zsh_autosuggest_accept 'original-widget'
|
||||
_zsh_autosuggest_widget_accept 'original-widget'
|
||||
|
||||
assertTrue \
|
||||
'original widget not invoked' \
|
||||
|
@ -98,7 +98,7 @@ testViCursorNotAtEnd() {
|
|||
|
||||
stub _zsh_autosuggest_invoke_original_widget
|
||||
|
||||
_zsh_autosuggest_accept 'original-widget'
|
||||
_zsh_autosuggest_widget_accept 'original-widget'
|
||||
|
||||
assertTrue \
|
||||
'original widget not invoked' \
|
||||
|
|
|
@ -19,7 +19,7 @@ testClear() {
|
|||
BUFFER='ec'
|
||||
POSTDISPLAY='ho hello'
|
||||
|
||||
_zsh_autosuggest_clear 'original-widget'
|
||||
_zsh_autosuggest_widget_clear 'original-widget'
|
||||
|
||||
assertEquals \
|
||||
'BUFFER was modified' \
|
||||
|
|
|
@ -25,7 +25,7 @@ testModify() {
|
|||
_zsh_autosuggest_suggestion \
|
||||
'echo hello'
|
||||
|
||||
_zsh_autosuggest_modify 'original-widget'
|
||||
_zsh_autosuggest_widget_modify 'original-widget'
|
||||
|
||||
assertTrue \
|
||||
'original widget not invoked' \
|
||||
|
|
|
@ -25,7 +25,7 @@ testCursorMovesOutOfBuffer() {
|
|||
_zsh_autosuggest_invoke_original_widget \
|
||||
'CURSOR=5; LBUFFER="echo "; RBUFFER="hello"'
|
||||
|
||||
_zsh_autosuggest_partial_accept 'original-widget'
|
||||
_zsh_autosuggest_widget_partial_accept 'original-widget'
|
||||
|
||||
assertTrue \
|
||||
'original widget not invoked' \
|
||||
|
@ -51,7 +51,7 @@ testCursorStaysInBuffer() {
|
|||
_zsh_autosuggest_invoke_original_widget \
|
||||
'CURSOR=5; LBUFFER="echo "; RBUFFER="hello"'
|
||||
|
||||
_zsh_autosuggest_partial_accept 'original-widget'
|
||||
_zsh_autosuggest_widget_partial_accept 'original-widget'
|
||||
|
||||
assertTrue \
|
||||
'original widget not invoked' \
|
||||
|
|
|
@ -240,6 +240,8 @@ _zsh_autosuggest_modify() {
|
|||
_zsh_autosuggest_invoke_original_widget $@
|
||||
retval=$?
|
||||
|
||||
# Only fetch suggestions at the first level of widget recursion
|
||||
if [ -z "${funcstack[(rn:2:)_zsh_autosuggest_widget_*]}" ]; then
|
||||
# Get a new suggestion if the buffer is not empty after modification
|
||||
local suggestion
|
||||
if [ $#BUFFER -gt 0 ]; then
|
||||
|
@ -252,6 +254,7 @@ _zsh_autosuggest_modify() {
|
|||
else
|
||||
unset POSTDISPLAY
|
||||
fi
|
||||
fi
|
||||
|
||||
return $retval
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue