diff --git a/spec/integrations/vi_mode_spec.rb b/spec/integrations/vi_mode_spec.rb index cf471b5..0a295c2 100644 --- a/spec/integrations/vi_mode_spec.rb +++ b/spec/integrations/vi_mode_spec.rb @@ -63,5 +63,18 @@ describe 'when using vi mode' do end end end -end + describe '`vi-delete`' do + it 'should be able to remove the last character in the buffer' do + skip 'deleting last char did not work below zsh version 5.0.8' if session.zsh_version < Gem::Version.new('5.0.8') + + session. + send_string('echo foo'). + send_keys('escape'). + send_keys('d'). + send_keys('l') + + wait_for { session.content }.to eq('echo fo') + end + end +end diff --git a/src/widgets.zsh b/src/widgets.zsh index 450ed3c..2d8be5e 100644 --- a/src/widgets.zsh +++ b/src/widgets.zsh @@ -136,7 +136,7 @@ _zsh_autosuggest_accept() { unset POSTDISPLAY # Move the cursor to the end of the buffer - CURSOR=${#BUFFER} + CURSOR=${max_cursor_pos} fi _zsh_autosuggest_invoke_original_widget $@ diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index cd68f69..8384e7c 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -398,7 +398,7 @@ _zsh_autosuggest_accept() { unset POSTDISPLAY # Move the cursor to the end of the buffer - CURSOR=${#BUFFER} + CURSOR=${max_cursor_pos} fi _zsh_autosuggest_invoke_original_widget $@