Use lazy enumeration to keep response time fast.
With HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE, it can take a while to compute all unique search results, which would normally keep the shell unresponsive during this computation. This commit separates the retrieval of all history matches from the computation of the matches that need to be presented to the user (unique matches only if HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set). The computation of the matches needing to be displayed is then done lazily, and only when the user requests a new previously undisplayed result. This keeps the response time fast while still enabling us to filter for unique search results.
This commit is contained in:
parent
352943873d
commit
8224802bda
2 changed files with 244 additions and 126 deletions
20
README.md
20
README.md
|
|
@ -102,13 +102,19 @@ default values only after having loaded this script into your ZSH session.
|
|||
Flags" section in the zshexpn(1) man page to learn about the kinds of
|
||||
values you may assign to this variable.
|
||||
|
||||
To always receive _unique_ search results, use `setopt HIST_IGNORE_ALL_DUPS`.
|
||||
Alternatively, use `setopt HIST_FIND_NO_DUPS` which makes this plugin skip
|
||||
duplicate _adjacent_ search results as you cycle through them---however, this
|
||||
does not guarantee that search results are unique: if your search results were
|
||||
"Dog", "Dog", "HotDog", "Dog", then cycling them gives "Dog", "HotDog", "Dog".
|
||||
Notice that the "Dog" search result appeared twice as you cycled through them!
|
||||
If you wish to avoid this limitation, then use `setopt HIST_IGNORE_ALL_DUPS`.
|
||||
* HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is a global variable that defines
|
||||
whether all search results returned are _unique_. If set to a non-empty
|
||||
value, then only unique search results are presented. It is unset by
|
||||
default. An alternative way to ensure that search results are unique is
|
||||
to use `setopt HIST_IGNORE_ALL_DUPS`. If both this configuration variable
|
||||
and `setopt HIST_IGNORE_ALL_DUPS` are unset, then `setopt HIST_FIND_NO_DUPS`
|
||||
is still respected, and makes this plugin skip duplicate _adjacent_ search
|
||||
results as you cycle through them, but this does not guarantee that search
|
||||
results are unique: if your search results were "Dog", "Dog", "HotDog",
|
||||
"Dog", then cycling them gives "Dog", "HotDog", "Dog". Notice that the "Dog"
|
||||
search result appeared twice as you cycled through them. If you wish to
|
||||
receive globally unique search results only once, then set this
|
||||
configuration variable, or use `setopt HIST_IGNORE_ALL_DUPS`.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
History
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue