This commit is contained in:
Arnaud Venturi 2018-05-07 11:38:32 +00:00 committed by GitHub
commit e680d7565b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,13 @@
describe 'a vicmd mode partial-accept widget' do
let(:widget) { 'vi-forward-word-end' }
context 'in vicmd mode' do
it 'moves the cursor through suggestion as expected' do
session.run_command("bindkey s vi-cmd-mode")
with_history('foobar foo') do
session.send_string('fo').send_keys('s').send_keys('e').send_keys('a').send_string('plop')
wait_for { session.content }.to eq('foobarplop')
end
end
end
end

View File

@ -164,6 +164,13 @@ _zsh_autosuggest_partial_accept() {
_zsh_autosuggest_invoke_original_widget $@
retval=$?
# 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
# working even in thi case.
if [[ "$KEYMAP" = "vicmd" ]]; then
(( CURSOR++ ))
fi
# If we've moved past the end of the original buffer
if (( $CURSOR > $#original_buffer )); then
# Set POSTDISPLAY to text right of the cursor
@ -176,6 +183,11 @@ _zsh_autosuggest_partial_accept() {
BUFFER="$original_buffer"
fi
# Restore CURSOR
if [[ "$KEYMAP" = "vicmd" ]]; then
(( CURSOR-- ))
fi
return $retval
}

View File

@ -442,6 +442,13 @@ _zsh_autosuggest_partial_accept() {
_zsh_autosuggest_invoke_original_widget $@
retval=$?
# 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
# working even in thi case.
if [[ "$KEYMAP" = "vicmd" ]]; then
(( CURSOR++ ))
fi
# 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 +461,11 @@ _zsh_autosuggest_partial_accept() {
BUFFER="$original_buffer"
fi
# Restore CURSOR
if [[ "$KEYMAP" = "vicmd" ]]; then
(( CURSOR-- ))
fi
return $retval
}