Merge pull request #41 from parkercoates/master

GH-19: Respect the HIST_FIND_NO_DUPS option.
This commit is contained in:
Suraj N. Kurapati 2015-03-17 10:59:44 -07:00
commit 5866858947

View file

@ -200,12 +200,19 @@ function _history-substring-search-begin() {
#
# Find all occurrences of the search query in the history file.
#
# (k) turns it an array of line numbers.
# (k) returns the "keys" (history index numbers) instead of the values
# (Oa) reverses the order, because (R) returns results reversed.
#
# (on) seems to remove duplicates, which are default
# options. They can be turned off by (ON).
#
_history_substring_search_matches=(${(kon)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