From 3f4c2acd53d157bf1b55031d3f93ee9055c6742f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20V=C3=A4th?= Date: Mon, 18 Jun 2018 19:47:27 +0200 Subject: [PATCH 1/2] Do not leak global variables REPLY and strategy https://github.com/zsh-users/zsh-autosuggestions/issues/341 --- zsh-autosuggestions.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 8aad4c8..17e0d52 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -587,7 +587,7 @@ _zsh_autosuggest_capture_buffer() { _zsh_autosuggest_capture_completion() { typeset -g completion - local line + local line REPLY # Zle will be inactive if we are in async mode if zle; then @@ -716,6 +716,7 @@ _zsh_autosuggest_strategy_match_prev_cmd() { _zsh_autosuggest_fetch_suggestion() { typeset -g suggestion local -a strategies + local strategy # Ensure we are working with an array strategies=(${=ZSH_AUTOSUGGEST_STRATEGY}) From 2d0806a362f3525fc4c3358116a3ff22eaf486a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20V=C3=A4th?= Date: Mon, 18 Jun 2018 19:58:06 +0200 Subject: [PATCH 2/2] Offer suggestion only if cursor is at end of line https://github.com/zsh-users/zsh-autosuggestions/issues/343 --- zsh-autosuggestions.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 17e0d52..5927bd9 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -379,6 +379,7 @@ _zsh_autosuggest_modify() { # Fetch a new suggestion based on what's currently in the buffer _zsh_autosuggest_fetch() { + [[ $CURSOR -eq $#BUFFER ]] || return 0 if [[ -n "${ZSH_AUTOSUGGEST_USE_ASYNC+x}" ]]; then _zsh_autosuggest_async_request "$BUFFER" else