Fix block formatting issues (#1354)
This commit is contained in:
@@ -1750,6 +1750,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
# Remove existing format first, if any
|
# Remove existing format first, if any
|
||||||
theText = theBlock.text()
|
theText = theBlock.text()
|
||||||
|
hasText = len(theText) > 0
|
||||||
if theText.startswith("@"):
|
if theText.startswith("@"):
|
||||||
logger.error("Cannot apply block format to keyword/value line")
|
logger.error("Cannot apply block format to keyword/value line")
|
||||||
return False
|
return False
|
||||||
@@ -1855,11 +1856,17 @@ class GuiDocEditor(QTextEdit):
|
|||||||
posS = theCursor.selectionStart()
|
posS = theCursor.selectionStart()
|
||||||
theCursor.removeSelectedText()
|
theCursor.removeSelectedText()
|
||||||
theCursor.setPosition(posS)
|
theCursor.setPosition(posS)
|
||||||
if posS > 0:
|
|
||||||
|
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.insertBlock()
|
||||||
|
|
||||||
theCursor.insertText(theText)
|
theCursor.insertText(theText)
|
||||||
|
|
||||||
if posO - cOffset >= 0:
|
if posO - cOffset >= 0:
|
||||||
theCursor.setPosition(posO - cOffset)
|
theCursor.setPosition(posO - cOffset)
|
||||||
|
|
||||||
theCursor.endEditBlock()
|
theCursor.endEditBlock()
|
||||||
self.setTextCursor(theCursor)
|
self.setTextCursor(theCursor)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user