From a2d8d91196c31425886f34bae3b8c55995c8fd98 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Tue, 16 Feb 2016 09:33:26 -0700 Subject: [PATCH] Actually fix suggestions when `sh_split_words` option is enabled. --- src/suggestion.zsh | 9 ++------- zsh-autosuggestions.zsh | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/suggestion.zsh b/src/suggestion.zsh index fd94d4c..5eff64f 100644 --- a/src/suggestion.zsh +++ b/src/suggestion.zsh @@ -8,12 +8,7 @@ _zsh_autosuggest_suggestion() { setopt localoptions extendedglob # Escape the prefix (requires EXTENDED_GLOB) - local prefix=${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH} + local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}" - # Get all history items (reversed) that match pattern $prefix* - local history_matches - history_matches=(${history[(R)$prefix*]}) - - # Echo the first item that matches - echo ${history_matches[1]} + fc -ln -m "$prefix*" 2>/dev/null | tail -1 } diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 431b816..ec79944 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -291,14 +291,9 @@ _zsh_autosuggest_suggestion() { setopt localoptions extendedglob # Escape the prefix (requires EXTENDED_GLOB) - local prefix=${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH} + local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}" - # Get all history items (reversed) that match pattern $prefix* - local history_matches - history_matches=(${history[(R)$prefix*]}) - - # Echo the first item that matches - echo ${history_matches[1]} + fc -ln -m "$prefix*" 2>/dev/null | tail -1 } #--------------------------------------------------------------------#