Only fetch a new suggestion if buffer has changed

This commit is contained in:
Eric Freese
2016-07-31 20:10:22 -06:00
parent a44aa59321
commit b377c39d0e
3 changed files with 23 additions and 3 deletions

View File

@@ -256,13 +256,23 @@ _zsh_autosuggest_clear() {
_zsh_autosuggest_modify() {
local -i retval
# Save the contents of the buffer/postdisplay
local orig_buffer="$BUFFER"
local orig_postdisplay="$POSTDISPLAY"
# Clear suggestion while original widget runs
unset POSTDISPLAY
# Original widget modifies the buffer
# Original widget may modify the buffer
_zsh_autosuggest_invoke_original_widget $@
retval=$?
# Don't fetch a new suggestion if the buffer hasn't changed
if [ "$BUFFER" = "$orig_buffer" ]; then
POSTDISPLAY="$orig_postdisplay"
return $retval
fi
# Get a new suggestion if the buffer is not empty after modification
local suggestion
if [ $#BUFFER -gt 0 ]; then