diff --git a/src/widgets.zsh b/src/widgets.zsh index 7562897..28d88eb 100644 --- a/src/widgets.zsh +++ b/src/widgets.zsh @@ -162,11 +162,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 $@ @@ -186,8 +188,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 diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index e780225..47d73c6 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -426,11 +426,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 $@ @@ -450,8 +452,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