From 710ad598d99cec0974f47dcfa5ebbfeb3c67dcbc Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 11 Oct 2020 20:34:51 +0200 Subject: [PATCH] Count words when saving editor text --- nw/gui/doceditor.py | 5 +++++ nw/gui/projtree.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 1d1d2a4e..13c67650 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -360,9 +360,14 @@ class GuiDocEditor(QTextEdit): return False docText = self.getText() + + cC, wC, pC = countWords(docText) + self._updateCounts(cC, wC, pC) + theItem.setCharCount(self.charCount) theItem.setWordCount(self.wordCount) theItem.setParaCount(self.paraCount) + self.saveCursorPosition() self.nwDocument.saveDocument(docText) self.setDocumentChanged(False) diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 858948dc..2d8900cf 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -241,7 +241,8 @@ class GuiProjectTree(QTreeWidget): # Add the new item to the tree if tHandle is not None: self.revealNewTreeItem(tHandle, nHandle) - self.theParent.editItem(tHandle) + if self.mainConf.showGUI: + self.theParent.editItem(tHandle) return True