mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-23 10:21:15 +01:00
fix a bug in partial acceptance of suggestions
To reproduce: 1. Run `zsh -f`. 2. Run this: function bye() { BUFFER=bye } zle -N bye bindkey '^B' bye print -s 'hibye unexpected' source ~/zsh-autosuggestions/zsh-autosuggestions.zsh 3. Type `hi` and press Ctrl-B. Expected: POSTBUFFER is empty. Actual: POSTBUFFER is " unexpected".
This commit is contained in:
parent
ae315ded4d
commit
e0b96e1bd6
2 changed files with 6 additions and 28 deletions
|
@ -61,20 +61,9 @@ _zsh_autosuggest_modify() {
|
|||
return $retval
|
||||
fi
|
||||
|
||||
# Optimize if manually typing in the suggestion
|
||||
if (( $#BUFFER > $#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"
|
||||
# Optimize if manually typing in the suggestion or if buffer hasn't changed
|
||||
if [[ "$BUFFER" = "$orig_buffer"* && "$orig_postdisplay" = "${BUFFER:$#orig_buffer}"* ]]; then
|
||||
POSTDISPLAY="${orig_postdisplay:$(($#BUFFER - $#orig_buffer))}"
|
||||
return $retval
|
||||
fi
|
||||
|
||||
|
|
|
@ -323,20 +323,9 @@ _zsh_autosuggest_modify() {
|
|||
return $retval
|
||||
fi
|
||||
|
||||
# Optimize if manually typing in the suggestion
|
||||
if (( $#BUFFER > $#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"
|
||||
# Optimize if manually typing in the suggestion or if buffer hasn't changed
|
||||
if [[ "$BUFFER" = "$orig_buffer"* && "$orig_postdisplay" = "${BUFFER:$#orig_buffer}"* ]]; then
|
||||
POSTDISPLAY="${orig_postdisplay:$(($#BUFFER - $#orig_buffer))}"
|
||||
return $retval
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue