Skip to content

Commit 7ef8835

Browse files
authored
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.
1 parent d6a4c0c commit 7ef8835

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

MenuApplets/ClipboardHistory/ClipboardHistoryModel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ void ClipboardHistoryModel::update()
8989

9090
void ClipboardHistoryModel::add_item(const GUI::Clipboard::DataAndType& item)
9191
{
92+
m_history_items.remove_first_matching([&](GUI::Clipboard::DataAndType& existing) {
93+
return existing.data == item.data && existing.mime_type == item.mime_type;
94+
});
95+
9296
if (m_history_items.size() == m_history_limit)
9397
m_history_items.take_last();
98+
9499
m_history_items.prepend(item);
95100
update();
96101
}

0 commit comments

Comments
 (0)