mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-02-06 09:55:30 +08:00
First try to fix partial accept in vicmd mode
This commit is contained in:
parent
60aff2d944
commit
bf95b4c093
@ -438,10 +438,26 @@ _zsh_autosuggest_partial_accept() {
|
||||
# Temporarily accept the suggestion.
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
print keymap: $KEYMAP >> /tmp/zsh_autosuggest_log
|
||||
print original widget name: $@ >> /tmp/zsh_autosuggest_log
|
||||
print original buffer: $original_buffer >> /tmp/zsh_autosuggest_log
|
||||
print original postdisplay: $POSTDISPLAY >> /tmp/zsh_autosuggest_log
|
||||
print original cursor: $CURSOR >> /tmp/zsh_autosuggest_log
|
||||
|
||||
# Original widget moves the cursor
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
retval=$?
|
||||
|
||||
# In vicmd keymap, the cursor is placed on the last character, not after
|
||||
# For this reason, we need to increment it by 1 for our tests on it to
|
||||
# keep working, then roll it back to its initial value
|
||||
if [ $KEYMAP = 'vicmd' ]; then
|
||||
(( CURSOR++ ))
|
||||
fi
|
||||
|
||||
print retval: $retval >> /tmp/zsh_autosuggest_log
|
||||
print final cursor: $CURSOR >> /tmp/zsh_autosuggest_log
|
||||
|
||||
# If we've moved past the end of the original buffer
|
||||
if (( $CURSOR > $#original_buffer )); then
|
||||
# Set POSTDISPLAY to text right of the cursor
|
||||
@ -454,6 +470,11 @@ _zsh_autosuggest_partial_accept() {
|
||||
BUFFER="$original_buffer"
|
||||
fi
|
||||
|
||||
if [ $KEYMAP = 'vicmd' ]; then
|
||||
(( CURSOR-- ))
|
||||
fi
|
||||
|
||||
print '' >> /tmp/zsh_autosuggest_log
|
||||
return $retval
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user