mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-23 10:21:15 +01:00
Fix #164: Use fc
builtin instead of $history
array for lookup
According to a few tests, the `fc` builtin appears to be quite a bit faster than searching through the `$history` associative array when dealing with large history files (500K+).
This commit is contained in:
parent
b4b3a82ee3
commit
63816c5da8
2 changed files with 2 additions and 16 deletions
|
@ -7,12 +7,5 @@
|
|||
#
|
||||
|
||||
_zsh_autosuggest_strategy_default() {
|
||||
local prefix="$1"
|
||||
|
||||
# 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]]}"
|
||||
fc -lnrm "$1*" 1 2>/dev/null | head -n 1
|
||||
}
|
||||
|
|
|
@ -371,14 +371,7 @@ _zsh_autosuggest_escape_command() {
|
|||
#
|
||||
|
||||
_zsh_autosuggest_strategy_default() {
|
||||
local prefix="$1"
|
||||
|
||||
# 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]]}"
|
||||
fc -lnrm "$1*" 1 2>/dev/null | head -n 1
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
|
|
Loading…
Reference in a new issue