mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-04-17 11:35:31 +08:00

Maybe this is also a fix for #247, #248 and #258. Supersedes #267. Testcase: Using match_prev_cmd strategy and with these lines in history: echo '1^' echo '2^' echo '1^' type: echo (unexpected suggestion echo '1^' instead of echo '2^') echo '1^1 (wrong suggestion echo '1^1echo '1^') echo '1^# (error "bad math expression")
16 lines
487 B
Bash
16 lines
487 B
Bash
|
|
#--------------------------------------------------------------------#
|
|
# Default Suggestion Strategy #
|
|
#--------------------------------------------------------------------#
|
|
# Suggests the most recent history item that matches the given
|
|
# prefix.
|
|
#
|
|
|
|
_zsh_autosuggest_strategy_default() {
|
|
local prefix="$1"
|
|
|
|
# Get the history items that match
|
|
# - (r) subscript flag makes the pattern match on values
|
|
suggestion="${history[(r)${(b)prefix}*]}"
|
|
}
|