mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
Remove duplicates from history in fish_config
https://github.com/fish-shell/fish-shell/issues/900
This commit is contained in:
parent
3816abb9de
commit
5ef13d9011
1 changed files with 11 additions and 0 deletions
11
history.cpp
11
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());
|
||||
|
|
Loading…
Reference in a new issue