From 0dc07de77d5d3e865b43913b4a49789681b288b1 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 14 Oct 2020 18:20:41 +0200 Subject: [PATCH] Also handle multi-paragraph formatting for quotes --- nw/gui/doceditor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 9ce47cbd..d5e3b045 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -1237,6 +1237,11 @@ class GuiDocEditor(QTextEdit): posS = theCursor.selectionStart() posE = theCursor.selectionEnd() + blockS = self.qDocument.findBlock(posS) + blockE = self.qDocument.findBlock(posE) + if blockS != blockE: + posE = blockS.position() + blockS.length() - 1 + theCursor.clearSelection() theCursor.beginEditBlock() theCursor.setPosition(posE) @@ -1245,8 +1250,8 @@ class GuiDocEditor(QTextEdit): theCursor.insertText(tBefore) theCursor.endEditBlock() - theCursor.setPosition(posE + len(tBefore)) - theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, posE-posS) + theCursor.setPosition(posE + len(tBefore), QTextCursor.MoveAnchor) + theCursor.setPosition(posS + len(tBefore), QTextCursor.KeepAnchor) self.setTextCursor(theCursor) else: