diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index caee97b9..d73f0abb 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -245,9 +245,6 @@ class GuiDocViewer(QTextBrowser): }) self.updateDocMargins() - # Since we change the content while it may still be rendering, we mark - # the document dirty again to make sure it's re-rendered properly. - self.redrawText() QApplication.restoreOverrideCursor() self.documentLoaded.emit(tHandle) @@ -259,12 +256,6 @@ class GuiDocViewer(QTextBrowser): self.loadText(self._docHandle, updateHistory=False) return - def redrawText(self) -> None: - """Redraw the text by marking the content as "dirty".""" - self.document().markContentsDirty(0, self.document().characterCount()) - self.updateDocMargins() - return - def docAction(self, action: nwDocAction) -> bool: """Process document actions on the current document.""" logger.debug("Requesting action: '%s'", action.name) diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index 0cfe156d..3d6eaf00 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -616,6 +616,10 @@ class GuiMain(QMainWindow): # Make sure main tab is in Editor view self._changeView(nwView.EDITOR) + # If we're loading the document in the editor, it may need to be saved + if tHandle == self.docEditor.docHandle and self.docEditor.docChanged: + self.saveDocument() + logger.debug("Viewing document with handle '%s'", tHandle) updateHistory = tHandle != self.docViewer.docHandle if self.docViewer.loadText(tHandle, updateHistory=updateHistory):