From e9868744f4d7343b799301e0bfe328af6bac32b7 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 10 Oct 2020 17:58:22 +0200 Subject: [PATCH] Remove the total line count, and trigger the update *after* the key/mouse events --- nw/gui/doceditor.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index d4498b5e..1d1d2a4e 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -740,8 +740,9 @@ class GuiDocEditor(QTextEdit): elif keyEvent == QKeySequence.Undo: self.docAction(nwDocAction.UNDO) else: - self.docFooter.updateLineCount() QTextEdit.keyPressEvent(self, keyEvent) + self.docFooter.updateLineCount() + return def focusNextPrevChild(self, toNext): @@ -764,8 +765,10 @@ class GuiDocEditor(QTextEdit): if qApp.keyboardModifiers() == Qt.ControlModifier: theCursor = self.cursorForPosition(mEvent.pos()) self._followTag(theCursor) - self.docFooter.updateLineCount() + QTextEdit.mouseReleaseEvent(self, mEvent) + self.docFooter.updateLineCount() + return def resizeEvent(self, theEvent): @@ -2205,7 +2208,7 @@ class GuiDocEditFooter(QWidget): self.linesIcon.setFixedHeight(self.sPx) self.linesIcon.setAlignment(Qt.AlignLeft | Qt.AlignTop) - self.linesText = QLabel("Line: 0 of 0") + self.linesText = QLabel("Line: 0") self.linesText.setIndent(0) self.linesText.setMargin(0) self.linesText.setContentsMargins(0, 0, 0, 0) @@ -2295,13 +2298,11 @@ class GuiDocEditFooter(QWidget): """ if self.theItem is None: iLine = 0 - nLine = 0 else: theCursor = self.docEditor.textCursor() iLine = theCursor.blockNumber() + 1 - nLine = self.docEditor.qDocument.blockCount() - self.linesText.setText("Line: %d of %d" % (iLine, nLine)) + self.linesText.setText(f"Line: {iLine:n}") return