mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-08 15:32:31 +01:00
Revert fc usage in calculating suggestion
As far as I know, `fc` makes it impossible to tell whether history items used an actual newline character or the string "\n". Pulling from the `$history` array gives a more accurate representation of the actual command that was run.
This commit is contained in:
parent
8e06a54b1c
commit
0305908adf
3 changed files with 17 additions and 3 deletions
|
|
@ -421,7 +421,14 @@ zle -N _autosuggest-show-suggestion _zsh_autosuggest_show_suggestion
|
|||
_zsh_autosuggest_strategy_default() {
|
||||
setopt localoptions EXTENDED_GLOB
|
||||
|
||||
fc -lnrm "${1//(#m)[\\()\[\]|*?~]/\\$MATCH}*" 1 2>/dev/null | head -n 1
|
||||
local prefix="${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
|
||||
|
||||
# Get the keys of the history items that match
|
||||
local -a histkeys
|
||||
histkeys=(${(k)history[(r)$prefix*]})
|
||||
|
||||
# Echo the value of the first key
|
||||
echo -E "${history[$histkeys[1]]}"
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue