Skip to content

Commit 146020d

Browse files
authored
Merge pull request #454 from zsh-users/develop
v0.6.3
2 parents c806055 + 0636a39 commit 146020d

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v0.6.3
4+
- Fixed bug moving cursor to end of buffer after accepting suggestion (#453)
5+
36
## v0.6.2
47
- Fixed bug deleting the last character in the buffer in vi mode (#450)
58
- Degrade gracefully when user doesn't have `zsh/system` module installed (#447)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.6.2
1+
v0.6.3

spec/options/widget_lists_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do
66
let(:options) { ["ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})"] }
77

8-
it 'accepts the suggestion when invoked' do
8+
it 'accepts the suggestion and moves the cursor to the end of the buffer when invoked' do
99
with_history('echo hello') do
1010
session.send_string('e')
1111
wait_for { session.content }.to eq('echo hello')
1212
session.send_keys('C-b')
1313
wait_for { session.content(esc_seqs: true) }.to eq('echo hello')
14+
wait_for { session.cursor }.to eq([10, 0])
1415
end
1516
end
1617
end

src/widgets.zsh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ _zsh_autosuggest_accept() {
136136
unset POSTDISPLAY
137137

138138
# Move the cursor to the end of the buffer
139-
CURSOR=${max_cursor_pos}
139+
if [[ "$KEYMAP" = "vicmd" ]]; then
140+
CURSOR=$(($#BUFFER - 1))
141+
else
142+
CURSOR=$#BUFFER
143+
fi
140144
fi
141145

142146
_zsh_autosuggest_invoke_original_widget $@

zsh-autosuggestions.zsh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Fish-like fast/unobtrusive autosuggestions for zsh.
22
# https://github.com/zsh-users/zsh-autosuggestions
3-
# v0.6.2
3+
# v0.6.3
44
# Copyright (c) 2013 Thiago de Arruda
55
# Copyright (c) 2016-2019 Eric Freese
66
#
@@ -398,7 +398,11 @@ _zsh_autosuggest_accept() {
398398
unset POSTDISPLAY
399399

400400
# Move the cursor to the end of the buffer
401-
CURSOR=${max_cursor_pos}
401+
if [[ "$KEYMAP" = "vicmd" ]]; then
402+
CURSOR=$(($#BUFFER - 1))
403+
else
404+
CURSOR=$#BUFFER
405+
fi
402406
fi
403407

404408
_zsh_autosuggest_invoke_original_widget $@

0 commit comments

Comments
 (0)