Skip to content

Commit

Permalink
Clear POSTDISPLAY instead of unsetting
Browse files Browse the repository at this point in the history
We don't have any particular reason to unset. Clearing should be good
enough, and avoid any errors using unset parameters.

Cherry-picked from PR #634
  • Loading branch information
Joe Schaefer authored and ericfreese committed Sep 7, 2023
1 parent a593f4d commit 11d17e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/widgets.zsh
Expand Up @@ -30,7 +30,7 @@ _zsh_autosuggest_toggle() {
# Clear the suggestion
_zsh_autosuggest_clear() {
# Remove the suggestion
unset POSTDISPLAY
POSTDISPLAY=

_zsh_autosuggest_invoke_original_widget $@
}
Expand All @@ -47,7 +47,7 @@ _zsh_autosuggest_modify() {
local orig_postdisplay="$POSTDISPLAY"

# Clear suggestion while waiting for next one
unset POSTDISPLAY
POSTDISPLAY=

# Original widget may modify the buffer
_zsh_autosuggest_invoke_original_widget $@
Expand Down Expand Up @@ -102,7 +102,7 @@ _zsh_autosuggest_suggest() {
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
POSTDISPLAY="${suggestion#$BUFFER}"
else
unset POSTDISPLAY
POSTDISPLAY=
fi
}

Expand All @@ -128,7 +128,7 @@ _zsh_autosuggest_accept() {
BUFFER="$BUFFER$POSTDISPLAY"

# Remove the suggestion
unset POSTDISPLAY
POSTDISPLAY=

# Run the original widget before manually moving the cursor so that the
# cursor movement doesn't make the widget do something unexpected
Expand All @@ -151,7 +151,7 @@ _zsh_autosuggest_execute() {
BUFFER="$BUFFER$POSTDISPLAY"

# Remove the suggestion
unset POSTDISPLAY
POSTDISPLAY=

# Call the original `accept-line` to handle syntax highlighting or
# other potential custom behavior
Expand Down
10 changes: 5 additions & 5 deletions zsh-autosuggestions.zsh
Expand Up @@ -294,7 +294,7 @@ _zsh_autosuggest_toggle() {
# Clear the suggestion
_zsh_autosuggest_clear() {
# Remove the suggestion
unset POSTDISPLAY
POSTDISPLAY=

_zsh_autosuggest_invoke_original_widget $@
}
Expand All @@ -311,7 +311,7 @@ _zsh_autosuggest_modify() {
local orig_postdisplay="$POSTDISPLAY"

# Clear suggestion while waiting for next one
unset POSTDISPLAY
POSTDISPLAY=

# Original widget may modify the buffer
_zsh_autosuggest_invoke_original_widget $@
Expand Down Expand Up @@ -366,7 +366,7 @@ _zsh_autosuggest_suggest() {
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
POSTDISPLAY="${suggestion#$BUFFER}"
else
unset POSTDISPLAY
POSTDISPLAY=
fi
}

Expand All @@ -392,7 +392,7 @@ _zsh_autosuggest_accept() {
BUFFER="$BUFFER$POSTDISPLAY"

# Remove the suggestion
unset POSTDISPLAY
POSTDISPLAY=

# Run the original widget before manually moving the cursor so that the
# cursor movement doesn't make the widget do something unexpected
Expand All @@ -415,7 +415,7 @@ _zsh_autosuggest_execute() {
BUFFER="$BUFFER$POSTDISPLAY"

# Remove the suggestion
unset POSTDISPLAY
POSTDISPLAY=

# Call the original `accept-line` to handle syntax highlighting or
# other potential custom behavior
Expand Down

0 comments on commit 11d17e7

Please sign in to comment.