Add some comments to explain what's going on in the block formatting

This commit is contained in:
Veronica Berglyd Olsen
2023-02-10 20:07:52 +01:00
parent 5b20061607
commit aa3fe96158
+6
View File
@@ -1856,11 +1856,17 @@ class GuiDocEditor(QTextEdit):
posS = theCursor.selectionStart()
theCursor.removeSelectedText()
theCursor.setPosition(posS)
if posS > 0 and hasText:
# If the block already had text, we must insert a new block
# first before we can add back the text to it.
theCursor.insertBlock()
theCursor.insertText(theText)
if posO - cOffset >= 0:
theCursor.setPosition(posO - cOffset)
theCursor.endEditBlock()
self.setTextCursor(theCursor)