forked from qt-creator/qt-creator
Keep pinned files in Open Documents list when closed, but remove editor
This means that users can hit Ctrl+W out of habit and not have to worry about a pinned file closing. It will be out of their way but still easily accessible should they need it. Fixes: QTCREATORBUG-25964 Change-Id: Ic377cde021044cfc7f3ea1933293a81a6a8ac0fa Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1616,7 +1616,10 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
|
||||
QMultiHash<EditorView *, IEditor *> editorsPerView;
|
||||
for (IEditor *editor : std::as_const(acceptedEditors)) {
|
||||
emit m_instance->editorAboutToClose(editor);
|
||||
removeEditor(editor, flag != CloseFlag::Suspend);
|
||||
const DocumentModel::Entry *entry = DocumentModel::entryForDocument(editor->document());
|
||||
// If the file is pinned, closing it should remove the editor but keep it in Open Documents.
|
||||
const bool removeSuspendedEntry = !entry->pinned && flag != CloseFlag::Suspend;
|
||||
removeEditor(editor, removeSuspendedEntry);
|
||||
if (EditorView *view = viewForEditor(editor)) {
|
||||
editorsPerView.insert(view, editor);
|
||||
if (QApplication::focusWidget()
|
||||
@@ -3074,7 +3077,8 @@ bool EditorManager::closeDocuments(const QList<DocumentModel::Entry *> &entries)
|
||||
for (DocumentModel::Entry *entry : entries) {
|
||||
if (!entry)
|
||||
continue;
|
||||
if (entry->isSuspended)
|
||||
// Pinned files shouldn't be removed from Open Documents, even when pressing the "x" button.
|
||||
if (!entry->pinned && entry->isSuspended)
|
||||
DocumentModelPrivate::removeEntry(entry);
|
||||
else
|
||||
documentsToClose << entry->document;
|
||||
|
Reference in New Issue
Block a user