GH-19: Respect the HIST_FIND_NO_DUPS option.
This is the best way I've found to remove duplicate entries while keeping the most recent occurence, but I'm not a ZSH expert. There may be a more efficient way.
This commit is contained in:
parent
fd31074470
commit
13033d87a1
1 changed files with 9 additions and 0 deletions
|
|
@ -205,6 +205,15 @@ function _history-substring-search-begin() {
|
||||||
#
|
#
|
||||||
_history_substring_search_matches=(${(kOa)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]})
|
_history_substring_search_matches=(${(kOa)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]})
|
||||||
|
|
||||||
|
# Remove duplicate entries (keeping on the most recent) if HIST_FIND_NO_DUPS is set.
|
||||||
|
if [[ -o HIST_FIND_NO_DUPS ]]; then
|
||||||
|
local -A unique_matches
|
||||||
|
for n in $_history_substring_search_matches; do
|
||||||
|
unique_matches[${history[$n]}]="$n"
|
||||||
|
done
|
||||||
|
_history_substring_search_matches=(${(@n)unique_matches})
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Define the range of values that $_history_substring_search_match_index
|
# Define the range of values that $_history_substring_search_match_index
|
||||||
# can take: [0, $_history_substring_search_matches_count_plus].
|
# can take: [0, $_history_substring_search_matches_count_plus].
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue