mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-08 15:32:31 +01:00
Add ZSH_AUTOSUGGEST_MATCH_PREV_MAX_CMDS option
With this the until now hard-coded value of 200 can be configured.
This commit is contained in:
parent
afee79ef5b
commit
7a0c87155b
4 changed files with 17 additions and 4 deletions
|
|
@ -46,6 +46,11 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
|||
ZSH_AUTOSUGGEST_STRATEGY=(history)
|
||||
}
|
||||
|
||||
# Maximum number of commands to consider for match_prev_cmd strategy
|
||||
# Set to -1 to always use all matches
|
||||
(( ! ${+ZSH_AUTOSUGGEST_MATCH_PREV_MAX_CMDS} )) &&
|
||||
typeset -g ZSH_AUTOSUGGEST_MATCH_PREV_MAX_CMDS=200
|
||||
|
||||
# Widgets that clear the suggestion
|
||||
(( ! ${+ZSH_AUTOSUGGEST_CLEAR_WIDGETS} )) && {
|
||||
typeset -ga ZSH_AUTOSUGGEST_CLEAR_WIDGETS
|
||||
|
|
@ -710,9 +715,9 @@ _zsh_autosuggest_strategy_match_prev_cmd() {
|
|||
# Get the previously executed command
|
||||
local prev_cmd="$(_zsh_autosuggest_escape_command "${history[$((HISTCMD-1))]}")"
|
||||
|
||||
# Iterate up to the first 200 history event numbers that match $prefix
|
||||
# Iterate over the most recent history event numbers that match $prefix.
|
||||
local key
|
||||
for key in "${(@)history_match_keys[1,200]}"; do
|
||||
for key in "${(@)history_match_keys[1,$ZSH_AUTOSUGGEST_MATCH_PREV_MAX_CMDS]}"; do
|
||||
# Stop if we ran out of history
|
||||
[[ $key -gt 1 ]] || break
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue