From 609572bbb86aad54231fb1d261986e0b9ec3c726 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 15 Aug 2020 17:56:23 +0200 Subject: [PATCH] Modify the paragraph selection behaviour of Qt to not select paragraph separator --- nw/gui/doceditor.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 5eeef904..b382ec7e 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -1165,7 +1165,19 @@ class GuiDocEditor(QTextEdit): theCursor = self.textCursor() theCursor.clearSelection() theCursor.select(selMode) + + if selMode == QTextCursor.BlockUnderCursor: + # This selection mode also selects the preceding oaragraph + # separator, which we want to avoid. + posS = theCursor.selectionStart() + posE = theCursor.selectionEnd() + selTxt = theCursor.selectedText() + if selTxt.startswith(nwUnicode.U_PSEP): + theCursor.setPosition(posS+1, QTextCursor.MoveAnchor) + theCursor.setPosition(posE, QTextCursor.KeepAnchor) + self.setTextCursor(theCursor) + return def _beginSearch(self):