From c974b0215c44fcaa25a4de544f96139353b37b81 Mon Sep 17 00:00:00 2001 From: dail8859 Date: Thu, 5 Dec 2024 22:49:52 -0500 Subject: [PATCH] Fix loss when having a single temporary file If there was a single temporary file this was getting treated as a brand new, unmodified editor which means the app was treating this as one that could be closed since it was not needed. Closes #674 --- src/NotepadNext/dialogs/MainWindow.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 80ae7ee6d..6bf1ff9b5 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -901,10 +901,17 @@ ScintillaNext *MainWindow::getInitialEditor() if (editorCount() == 1) { ScintillaNext *editor = currentEditor(); - // If the editor has had ANY modifications, then don't call it an initial editor - if (!editor->isFile() && !editor->canUndo() && !editor->canRedo()) { - return editor; + // If the editor: + // is a temporary file + // is a 'real' file (or a 'missing' file) + // can undo any actions + // can redo any actions + // Then do not treat it as an 'initial editor' that can be transparently closed for the user + if (editor->isTemporary() || editor->isFile() || editor->canUndo() || editor->canRedo()) { + return Q_NULLPTR; } + + return editor; } return Q_NULLPTR;