Revert usage of fc for suggestions and fix for sh_word_split.

Force field splitting on \0 to support sh_word_split option.
This commit is contained in:
Eric Freese 2016-02-16 10:30:34 -07:00
parent 0faa2b6584
commit 6d25df6864
2 changed files with 12 additions and 2 deletions

View file

@ -10,5 +10,10 @@ _zsh_autosuggest_suggestion() {
# Escape the prefix (requires EXTENDED_GLOB) # Escape the prefix (requires EXTENDED_GLOB)
local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}" 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]"
} }

View file

@ -293,7 +293,12 @@ _zsh_autosuggest_suggestion() {
# Escape the prefix (requires EXTENDED_GLOB) # Escape the prefix (requires EXTENDED_GLOB)
local prefix="${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}" 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]"
} }
#--------------------------------------------------------------------# #--------------------------------------------------------------------#