ClipboardHistoryModel: Prevent duplicate rows (#4073)

Prevents the adding of items to the ClipboardHistoryModel if the raw
data and mime_type of the item being added is the same as another item
already in the list.
This commit is contained in:
Zac 2020-11-17 18:50:39 +10:00 committed by GitHub
parent d6a4c0c79e
commit 7ef8835e5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-19 01:21:39 +09:00

View file

@ -89,8 +89,13 @@ void ClipboardHistoryModel::update()
void ClipboardHistoryModel::add_item(const GUI::Clipboard::DataAndType& item)
{
m_history_items.remove_first_matching([&](GUI::Clipboard::DataAndType& existing) {
return existing.data == item.data && existing.mime_type == item.mime_type;
});
if (m_history_items.size() == m_history_limit)
m_history_items.take_last();
m_history_items.prepend(item);
update();
}