Editors: Update navigation history when closing with the tool button

The code path for the global actions (File menu, shortcut) were adding
the closed document to the history, but the editor view local action did
not. Move the call one level deeper, so it is done for both.

That fixes Window > Go Back under some circumstances in which it didn't open closed files again.

Change-Id: I74bdb02209b8ac7bb7714d9a827e3a0c30a4c9e9
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Eike Ziller
2024-05-07 13:50:56 +02:00
parent 732f37685c
commit 7eb09ff0b7

View File

@@ -1473,6 +1473,7 @@ bool EditorManagerPrivate::activateEditorForEntry(EditorView *view, DocumentMode
void EditorManagerPrivate::closeEditorOrDocument(IEditor *editor) void EditorManagerPrivate::closeEditorOrDocument(IEditor *editor)
{ {
QTC_ASSERT(editor, return); QTC_ASSERT(editor, return);
EditorManager::addCurrentPositionToNavigationHistory();
QList<IEditor *> visible = EditorManager::visibleEditors(); QList<IEditor *> visible = EditorManager::visibleEditors();
if (Utils::contains(visible, if (Utils::contains(visible,
[&editor](IEditor *other) { [&editor](IEditor *other) {
@@ -2690,7 +2691,6 @@ void EditorManager::slotCloseCurrentEditorOrDocument()
{ {
if (!d->m_currentEditor) if (!d->m_currentEditor)
return; return;
addCurrentPositionToNavigationHistory();
d->closeEditorOrDocument(d->m_currentEditor); d->closeEditorOrDocument(d->m_currentEditor);
} }