Only apply format to the first block when multiple blocks are selected

This commit is contained in:
Veronica K. B. Olsen
2020-10-14 13:43:18 +02:00
parent 1f957a2817
commit 8d64a6672f
2 changed files with 14 additions and 2 deletions
+1 -1
View File
@@ -955,4 +955,4 @@ class Config:
return
# End Class Config
# END Class Config
+13 -1
View File
@@ -1299,13 +1299,25 @@ class GuiDocEditor(QTextEdit):
return theCursor
def _toggleFormat(self, fLen, fChar):
"""Toggle strikethrough text.
"""Toggle the formatting of a specific type for a piece of text.
If more than one block is selected, the formatting is applied to
the first block.
"""
theCursor = self._autoSelect()
if theCursor.hasSelection():
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.setPosition(posS, QTextCursor.MoveAnchor)
theCursor.setPosition(posE, QTextCursor.KeepAnchor)
self.setTextCursor(theCursor)
numB = 0
for n in range(fLen):
if self.qDocument.characterAt(posS-n-1) == fChar: