Went back to modifying CURSOR directly

This commit is contained in:
Arnaud Venturi 2018-05-07 13:33:24 +02:00
parent 9619e2e779
commit c4c425a8a0
2 changed files with 18 additions and 10 deletions

View file

@ -166,14 +166,13 @@ _zsh_autosuggest_partial_accept() {
# In vicmd keymap, the cursor is placed on the current character # In vicmd keymap, the cursor is placed on the current character
# instead of after it. We increment it by 1 to keep the following logic # instead of after it. We increment it by 1 to keep the following logic
# working even in this case. # working even in thi case.
CURSOR_POS=$CURSOR if [ $KEYMAP = 'vicmd' ]; then
if [[ "$KEYMAP" = "vicmd" ]]; then (( CURSOR++ ))
(( CURSOR_POS++ ))
fi fi
# If we've moved past the end of the original buffer # If we've moved past the end of the original buffer
if (( $CURSOR_POS > $#original_buffer )); then if (( $CURSOR > $#original_buffer )); then
# Set POSTDISPLAY to text right of the cursor # Set POSTDISPLAY to text right of the cursor
POSTDISPLAY="$RBUFFER" POSTDISPLAY="$RBUFFER"
@ -184,6 +183,11 @@ _zsh_autosuggest_partial_accept() {
BUFFER="$original_buffer" BUFFER="$original_buffer"
fi fi
# Restore CURSOR
if [ $KEYMAP = 'vicmd' ]; then
(( CURSOR-- ))
fi
return $retval return $retval
} }

View file

@ -444,14 +444,13 @@ _zsh_autosuggest_partial_accept() {
# In vicmd keymap, the cursor is placed on the current character # In vicmd keymap, the cursor is placed on the current character
# instead of after it. We increment it by 1 to keep the following logic # instead of after it. We increment it by 1 to keep the following logic
# working even in this case. # working even in thi case.
CURSOR_POS=$CURSOR if [ $KEYMAP = 'vicmd' ]; then
if [[ "$KEYMAP" = "vicmd" ]]; then (( CURSOR++ ))
(( CURSOR_POS++ ))
fi fi
# If we've moved past the end of the original buffer # If we've moved past the end of the original buffer
if (( $CURSOR_POS > $#original_buffer )); then if (( $CURSOR > $#original_buffer )); then
# Set POSTDISPLAY to text right of the cursor # Set POSTDISPLAY to text right of the cursor
POSTDISPLAY="$RBUFFER" POSTDISPLAY="$RBUFFER"
@ -462,6 +461,11 @@ _zsh_autosuggest_partial_accept() {
BUFFER="$original_buffer" BUFFER="$original_buffer"
fi fi
# Restore CURSOR
if [ $KEYMAP = 'vicmd' ]; then
(( CURSOR-- ))
fi
return $retval return $retval
} }