Skip to content

Commit

Permalink
Fix loss when having a single temporary file
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dail8859 committed Dec 6, 2024
1 parent 6d9cd8e commit c974b02
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/NotepadNext/dialogs/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c974b02

Please sign in to comment.