Skip to content

Commit 2743a2e

Browse files
committed
Only capture completions at the end of the buffer.
To prevent the suggestion from not starting with the buffer string. Example: `ls / /[cursor left][cursor left]b` Before the patch, suggests `ls /b /ls /bin/ /` After the patch, suggests `ls /b /bin/`. #343 (comment)
1 parent 156ae5e commit 2743a2e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/strategies/completion.zsh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ _zsh_autosuggest_capture_completion_widget() {
1717
local -a +h comppostfuncs
1818
comppostfuncs=(_zsh_autosuggest_capture_postcompletion)
1919

20+
# Only capture completions at the end of the buffer
21+
CURSOR=$#BUFFER
22+
2023
# Run the original widget wrapping `.complete-word` so we don't
2124
# recursively try to fetch suggestions, since our pty is forked
2225
# after autosuggestions is initialized.

zsh-autosuggestions.zsh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ _zsh_autosuggest_capture_completion_widget() {
487487
local -a +h comppostfuncs
488488
comppostfuncs=(_zsh_autosuggest_capture_postcompletion)
489489

490+
# Only capture completions at the end of the buffer
491+
CURSOR=$#BUFFER
492+
490493
# Run the original widget wrapping `.complete-word` so we don't
491494
# recursively try to fetch suggestions, since our pty is forked
492495
# after autosuggestions is initialized.

0 commit comments

Comments
 (0)