From f1c3b98774bb52667fe3303ace477898aedd3b9b Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Mon, 2 Jul 2018 09:31:48 -0600 Subject: [PATCH] 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/`. https://github.com/zsh-users/zsh-autosuggestions/issues/343#issuecomment-401675712 --- src/strategies/completion.zsh | 3 +++ zsh-autosuggestions.zsh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/strategies/completion.zsh b/src/strategies/completion.zsh index 9b6341c..7517822 100644 --- a/src/strategies/completion.zsh +++ b/src/strategies/completion.zsh @@ -17,6 +17,9 @@ _zsh_autosuggest_capture_completion_widget() { local -a +h comppostfuncs comppostfuncs=(_zsh_autosuggest_capture_postcompletion) + # Only capture completions at the end of the buffer + CURSOR=$#BUFFER + # Run the original widget wrapping `.complete-word` so we don't # recursively try to fetch suggestions, since our pty is forked # after autosuggestions is initialized. diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 68f1bb1..be784b6 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -487,6 +487,9 @@ _zsh_autosuggest_capture_completion_widget() { local -a +h comppostfuncs comppostfuncs=(_zsh_autosuggest_capture_postcompletion) + # Only capture completions at the end of the buffer + CURSOR=$#BUFFER + # Run the original widget wrapping `.complete-word` so we don't # recursively try to fetch suggestions, since our pty is forked # after autosuggestions is initialized.