Editors: Fix that history of editors could grow

The "history of editors" is supposed to contain the order in which files/
documents were recently accessed. It is used for the "open documents
window" (the Ctrl+Tab popup). In contrast to the "navigation history" it
should contain each file/document only once.

Since 324de13b4e items for suspended
documents with the same file name were no longer removed. For suspended
documents it is necessary to check for the same file name.

This was so far not vital, but when we save the editor history in the
session, these do not have a document when restoring, which would lead
to an evergrowing editor history.

Amends 324de13b4e

Change-Id: Ia4b7848a1265024d0463afbf7c1cd69189c4be97
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2023-07-21 11:50:15 +02:00
parent 8d0aa34bfc
commit e98cc72980

View File

@@ -245,8 +245,10 @@ void EditorView::updateEditorHistory(IEditor *editor, QList<EditLocation> &histo
for (int i = 0; i < history.size(); ++i) {
const EditLocation &item = history.at(i);
if (item.document == document
|| (!item.document && !DocumentModel::indexOfFilePath(item.filePath))) {
// remove items that refer to the same document/file,
// or that are no longer in the "open documents"
if (item.document == document || (!item.document && item.filePath == document->filePath())
|| (!item.document && !DocumentModel::indexOfFilePath(item.filePath))) {
history.removeAt(i--);
}
}