Fix #141: Disable suggestions for widgets called from widgets

This commit is contained in:
Eric Freese 2016-04-29 14:46:24 -06:00
parent 62cdba4e0f
commit 9fb9675306
6 changed files with 34 additions and 28 deletions

View file

@ -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
}

View file

@ -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' \

View file

@ -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' \

View file

@ -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' \

View file

@ -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' \

View file

@ -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
}