mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-23 10:21:15 +01:00
Optimize case where manually typing in a suggestion
This commit is contained in:
parent
21d9eda5dd
commit
54e1eee924
2 changed files with 22 additions and 0 deletions
|
@ -26,6 +26,17 @@ _zsh_autosuggest_modify() {
|
|||
_zsh_autosuggest_invoke_original_widget $@
|
||||
retval=$?
|
||||
|
||||
# Optimize if manually typing in the suggestion
|
||||
if [ $#BUFFER -gt $#orig_buffer ]; then
|
||||
local added=${BUFFER#$orig_buffer}
|
||||
|
||||
# If the string added matches the beginning of the postdisplay
|
||||
if [ "$added" = "${orig_postdisplay:0:$#added}" ]; then
|
||||
POSTDISPLAY="${orig_postdisplay:$#added}"
|
||||
return $retval
|
||||
fi
|
||||
fi
|
||||
|
||||
# Don't fetch a new suggestion if the buffer hasn't changed
|
||||
if [ "$BUFFER" = "$orig_buffer" ]; then
|
||||
POSTDISPLAY="$orig_postdisplay"
|
||||
|
|
|
@ -291,6 +291,17 @@ _zsh_autosuggest_modify() {
|
|||
_zsh_autosuggest_invoke_original_widget $@
|
||||
retval=$?
|
||||
|
||||
# Optimize if manually typing in the suggestion
|
||||
if [ $#BUFFER -gt $#orig_buffer ]; then
|
||||
local added=${BUFFER#$orig_buffer}
|
||||
|
||||
# If the string added matches the beginning of the postdisplay
|
||||
if [ "$added" = "${orig_postdisplay:0:$#added}" ]; then
|
||||
POSTDISPLAY="${orig_postdisplay:$#added}"
|
||||
return $retval
|
||||
fi
|
||||
fi
|
||||
|
||||
# Don't fetch a new suggestion if the buffer hasn't changed
|
||||
if [ "$BUFFER" = "$orig_buffer" ]; then
|
||||
POSTDISPLAY="$orig_postdisplay"
|
||||
|
|
Loading…
Reference in a new issue