From 6d25df68641369876614b216826e138b3f67aa5b Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Tue, 16 Feb 2016 10:30:34 -0700 Subject: [PATCH] Revert usage of `fc` for suggestions and fix for sh_word_split. Force field splitting on \0 to support sh_word_split option. --- src/suggestion.zsh | 7 ++++++- zsh-autosuggestions.zsh | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/suggestion.zsh b/src/suggestion.zsh index 5eff64f..2b8bd77 100644 --- a/src/suggestion.zsh +++ b/src/suggestion.zsh @@ -10,5 +10,10 @@ _zsh_autosuggest_suggestion() { # Escape the prefix (requires EXTENDED_GLOB) local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}" - fc -ln -m "$prefix*" 2>/dev/null | tail -1 + # Get all history items (reversed) that match pattern $prefix* + local history_matches + history_matches=(${(j:\0:s:\0:)history[(R)$prefix*]}) + + # Echo the first item that matches + echo "$history_matches[1]" } diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 56e318d..ab1702c 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -293,7 +293,12 @@ _zsh_autosuggest_suggestion() { # Escape the prefix (requires EXTENDED_GLOB) local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}" - fc -ln -m "$prefix*" 2>/dev/null | tail -1 + # Get all history items (reversed) that match pattern $prefix* + local history_matches + history_matches=(${(j:\0:s:\0:)history[(R)$prefix*]}) + + # Echo the first item that matches + echo "$history_matches[1]" } #--------------------------------------------------------------------#