From a2f92c12232dc4f5662fe983e10ac738c4410535 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 1 Nov 2022 19:15:32 +0100 Subject: [PATCH] Auto-open first document on new project (#1219) --- novelwriter/guimain.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index f984d5d2..ae9529e6 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -534,7 +534,14 @@ class GuiMain(QMainWindow): self._updateStatusWordCount() # Restore previously open documents, if any + # If none was recorded, open the first document found lastEdited = self.theProject.data.getLastHandle("editor") + if lastEdited is None: + for nwItem in self.theProject.tree: + if nwItem and nwItem.isFileType(): + lastEdited = nwItem.itemHandle + break + if lastEdited is not None: self.openDocument(lastEdited, doScroll=True)