mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-23 08:40:23 +12:00
Temporary fix for: Undo/redo works in some text areas but not others #34
This commit is contained in:
parent
6bc74454c7
commit
6a88cb9aca
|
@ -41,9 +41,25 @@ class basicHighlighter(QSyntaxHighlighter):
|
|||
When subclassing basicHighlighter, you must call highlightBlockBefore
|
||||
before you do any custom highlighting.
|
||||
"""
|
||||
|
||||
#print(">", self.currentBlock().document().availableUndoSteps())
|
||||
c = QTextCursor(self.currentBlock())
|
||||
#c.joinPreviousEditBlock()
|
||||
bf = QTextBlockFormat(self._defaultBlockFormat)
|
||||
bf.setAlignment(QTextCursor(self.currentBlock()).blockFormat().alignment())
|
||||
QTextCursor(self.currentBlock()).setBlockFormat(bf)
|
||||
bf.setAlignment(c.blockFormat().alignment())
|
||||
c.setBlockFormat(bf)
|
||||
#c.endEditBlock()
|
||||
#print(" ", self.currentBlock().document().availableUndoSteps())
|
||||
|
||||
# This is an ugly fix.
|
||||
# Calling setBlockFormat adds an item to the undo stack. Don't know why,
|
||||
# or how to change that. So the stacks becomes big and it's impossible
|
||||
# to undo/redo any meaningful change.
|
||||
# Using QTextCursor.joinPreviousEditBlock() doesn't work.
|
||||
# But calling an undo after setting block format works: it doesn't undo
|
||||
# anything, and the stack is not filled.
|
||||
# FIXME: redo still doesn't work
|
||||
self.currentBlock().document().undo(c)
|
||||
|
||||
# self.setFormat(0, len(text), self._defaultCharFormat)
|
||||
|
||||
|
|
Loading…
Reference in a new issue