Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where partial accept duplicates last word #507

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/widgets.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,13 @@ _zsh_autosuggest_execute() {
_zsh_autosuggest_partial_accept() {
local -i retval cursor_loc

# Save the contents of the buffer so we can restore later if needed
# Save the original buffer/postdisplay so we can restore later if needed
local original_buffer="$BUFFER"
local original_postdisplay="$POSTDISPLAY"

# Temporarily accept the suggestion.
BUFFER="$BUFFER$POSTDISPLAY"
unset POSTDISPLAY

# Original widget moves the cursor
_zsh_autosuggest_invoke_original_widget $@
Expand All @@ -197,8 +199,9 @@ _zsh_autosuggest_partial_accept() {
# Clip the buffer at the cursor
BUFFER="${BUFFER[1,$cursor_loc]}"
else
# Restore the original buffer
# Restore the original buffer/postdisplay
BUFFER="$original_buffer"
POSTDISPLAY="$original_postdisplay"
fi

return $retval
Expand Down
7 changes: 5 additions & 2 deletions zsh-autosuggestions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,13 @@ _zsh_autosuggest_execute() {
_zsh_autosuggest_partial_accept() {
local -i retval cursor_loc

# Save the contents of the buffer so we can restore later if needed
# Save the original buffer/postdisplay so we can restore later if needed
local original_buffer="$BUFFER"
local original_postdisplay="$POSTDISPLAY"

# Temporarily accept the suggestion.
BUFFER="$BUFFER$POSTDISPLAY"
unset POSTDISPLAY

# Original widget moves the cursor
_zsh_autosuggest_invoke_original_widget $@
Expand All @@ -459,8 +461,9 @@ _zsh_autosuggest_partial_accept() {
# Clip the buffer at the cursor
BUFFER="${BUFFER[1,$cursor_loc]}"
else
# Restore the original buffer
# Restore the original buffer/postdisplay
BUFFER="$original_buffer"
POSTDISPLAY="$original_postdisplay"
fi

return $retval
Expand Down