aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-09-05 13:49:18 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-09-05 13:49:18 -0700
commit5ef13d901139498be42c1d2c47606914db2aa490 (patch)
tree62cce40a2c95640a1cb874ec010c828c80133a68
parent3816abb9def78bca7608401821dd388ad62ccea4 (diff)
Remove duplicates from history in fish_config
-rw-r--r--history.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/history.cpp b/history.cpp
index 8e3772d2..f167f6e4 100644
--- a/history.cpp
+++ b/history.cpp
@@ -629,10 +629,16 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
scoped_lock locker(lock);
bool first = true;
+
+ std::set<wcstring> seen;
/* Append new items. Note that in principle we could use const_reverse_iterator, but we do not because reverse_iterator is not convertible to const_reverse_iterator ( http://github.com/fish-shell/fish-shell/issues/431 ) */
for (std::vector<history_item_t>::reverse_iterator iter=new_items.rbegin(); iter < new_items.rend(); ++iter)
{
+ /* Skip duplicates */
+ if (! seen.insert(iter->str()).second)
+ continue;
+
if (! first)
result.append(separator);
result.append(iter->str());
@@ -645,6 +651,11 @@ void history_t::get_string_representation(wcstring &result, const wcstring &sepa
{
size_t offset = *iter;
const history_item_t item = history_t::decode_item(mmap_start + offset, mmap_length - offset, mmap_type);
+
+ /* Skip duplicates */
+ if (! seen.insert(item.str()).second)
+ continue;
+
if (! first)
result.append(separator);
result.append(item.str());