From e98cc72980e45deb67af2e759dbae23f44dd3ef4 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 21 Jul 2023 11:50:15 +0200 Subject: [PATCH] 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 324de13b4e6703db778010d0682ac26cff359516 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 324de13b4e6703db778010d0682ac26cff359516 Change-Id: Ia4b7848a1265024d0463afbf7c1cd69189c4be97 Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger Reviewed-by: David Schulz --- src/plugins/coreplugin/editormanager/editorview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 90aeb397525..84297254919 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -245,8 +245,10 @@ void EditorView::updateEditorHistory(IEditor *editor, QList &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--); } }