diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp index 19f0787e713..ff092dc04b4 100644 --- a/src/libs/utils/historycompleter.cpp +++ b/src/libs/utils/historycompleter.cpp @@ -146,10 +146,12 @@ void HistoryCompleterPrivate::clearHistory() void HistoryCompleterPrivate::saveEntry(const QString &str) { QTC_ASSERT(theSettings, return); - if (str.isEmpty()) - return; - if (list.contains(str)) - return; + int removeIndex = list.indexOf(str); + if (removeIndex != -1) { + beginRemoveRows(QModelIndex(), removeIndex, removeIndex); + list.removeAt(removeIndex); + endRemoveRows(); + } beginInsertRows (QModelIndex(), list.count(), list.count()); list.prepend(str); list = list.mid(0, maxLines);