Commit 9686c05c authored by Stefan Brüns's avatar Stefan Brüns

[KRunner] Avoid writing history if addToHistory is idempotent

Summary:
It is not uncommon to run the same command repeatedly. In this case,
the history is actually unchanged - the item is removed from the first
position, and prepended again.

Test Plan:
run the same command twice, config file is not rewritten
run a new command, config is updated

Reviewers: #plasma, broulik, apol

Reviewed By: #plasma, broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D20383
parent 4a5f62fe
......@@ -366,6 +366,11 @@ void View::addToHistory(const QString &item)
return;
}
// Avoid removing the same item from the front and prepending it again
if (!m_history.isEmpty() && m_history.constFirst() == item) {
return;
}
if (!KAuthorized::authorize(QStringLiteral("lineedit_text_completion"))) {
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment