From ca70612d3c7fa46ee56f6b7e8db6e1dc0618dd40 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sat, 28 May 2016 20:05:11 +0200 Subject: [PATCH] Document caveats of match_prev_cmd strategy This strategy relies on the history being exactly in the order in which commands have been entered. Therefore, options like suppressing duplicates or expiring duplicates first will lead to unexpected suggestions. --- README.md | 2 +- src/strategies/match_prev_cmd.zsh | 3 +++ zsh-autosuggestions.zsh | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bc6de0f..f1a0d20 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Set `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` to configure the style that the suggestion Set `ZSH_AUTOSUGGEST_STRATEGY` to choose the strategy for generating suggestions. There are currently two to choose from: - `default`: Chooses the most recent match. -- `match_prev_cmd`: Chooses the most recent match whose preceding history item matches the most recently executed command ([more info](src/strategies/match_prev_cmd.zsh)). +- `match_prev_cmd`: Chooses the most recent match whose preceding history item matches the most recently executed command ([more info](src/strategies/match_prev_cmd.zsh)). Note that this strategy won't work as expected with ZSH options that don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`. ### Widget Mapping diff --git a/src/strategies/match_prev_cmd.zsh b/src/strategies/match_prev_cmd.zsh index e71957e..bf8bdd9 100644 --- a/src/strategies/match_prev_cmd.zsh +++ b/src/strategies/match_prev_cmd.zsh @@ -16,6 +16,9 @@ # will be 'ls foo' rather than 'ls bar' because your most recently # executed command (pwd) was previously followed by 'ls foo'. # +# Note that this strategy won't work as expected with ZSH options that don't +# preserve the history order such as `HIST_IGNORE_ALL_DUPS` or +# `HIST_EXPIRE_DUPS_FIRST`. _zsh_autosuggest_strategy_match_prev_cmd() { local prefix="$1" diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 4e3c62e..7e44a77 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -398,6 +398,9 @@ _zsh_autosuggest_strategy_default() { # will be 'ls foo' rather than 'ls bar' because your most recently # executed command (pwd) was previously followed by 'ls foo'. # +# Note that this strategy won't work as expected with ZSH options that don't +# preserve the history order such as `HIST_IGNORE_ALL_DUPS` or +# `HIST_EXPIRE_DUPS_FIRST`. _zsh_autosuggest_strategy_match_prev_cmd() { local prefix="$1"