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 } #--------------------------------------------------------------------#