mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-04-17 11:35:31 +08:00
Merge 5fd85405b3
into 60aff2d944
This commit is contained in:
commit
e680d7565b
13
spec/integrations/vicmd_partial_accept_spec.rb
Normal file
13
spec/integrations/vicmd_partial_accept_spec.rb
Normal 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
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user