mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Using a separate variable instead of rolling back CURSOR to its initial value
This commit is contained in:
parent
603132c6b8
commit
b9345ebceb
2 changed files with 8 additions and 16 deletions
|
@ -166,13 +166,14 @@ _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 thi case.
|
# working even in this 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 > $#original_buffer )); then
|
if (( $CURSOR_POS > $#original_buffer )); then
|
||||||
# Set POSTDISPLAY to text right of the cursor
|
# Set POSTDISPLAY to text right of the cursor
|
||||||
POSTDISPLAY="$RBUFFER"
|
POSTDISPLAY="$RBUFFER"
|
||||||
|
|
||||||
|
@ -183,11 +184,6 @@ _zsh_autosuggest_partial_accept() {
|
||||||
BUFFER="$original_buffer"
|
BUFFER="$original_buffer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore CURSOR
|
|
||||||
if [ $KEYMAP = 'vicmd' ]; then
|
|
||||||
(( CURSOR-- ))
|
|
||||||
fi
|
|
||||||
|
|
||||||
return $retval
|
return $retval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,13 +444,14 @@ _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 thi case.
|
# working even in this 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 > $#original_buffer )); then
|
if (( $CURSOR_POS > $#original_buffer )); then
|
||||||
# Set POSTDISPLAY to text right of the cursor
|
# Set POSTDISPLAY to text right of the cursor
|
||||||
POSTDISPLAY="$RBUFFER"
|
POSTDISPLAY="$RBUFFER"
|
||||||
|
|
||||||
|
@ -461,11 +462,6 @@ _zsh_autosuggest_partial_accept() {
|
||||||
BUFFER="$original_buffer"
|
BUFFER="$original_buffer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore CURSOR
|
|
||||||
if [ $KEYMAP = 'vicmd' ]; then
|
|
||||||
(( CURSOR-- ))
|
|
||||||
fi
|
|
||||||
|
|
||||||
return $retval
|
return $retval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue