diff --git a/src/ui/editors/basicHighlighter.py b/src/ui/editors/basicHighlighter.py index 02621398..a712bdcc 100644 --- a/src/ui/editors/basicHighlighter.py +++ b/src/ui/editors/basicHighlighter.py @@ -29,7 +29,9 @@ class basicHighlighter(QSyntaxHighlighter): """Apply syntax highlighting to the given block of text. """ - QTextCursor(self.currentBlock()).setBlockFormat(self._defaultBlockFormat) + bf = QTextBlockFormat(self._defaultBlockFormat) + bf.setAlignment(QTextCursor(self.currentBlock()).blockFormat().alignment()) + QTextCursor(self.currentBlock()).setBlockFormat(bf) #self.setFormat(0, len(text), self._defaultCharFormat) # Spell checking diff --git a/src/ui/views/textEditView.py b/src/ui/views/textEditView.py index 25b8a94f..9ef47451 100644 --- a/src/ui/views/textEditView.py +++ b/src/ui/views/textEditView.py @@ -456,15 +456,15 @@ class textEditView(QTextEdit): cursor = self.textCursor() - bf = cursor.blockFormat() + #bf = cursor.blockFormat() + bf = QTextBlockFormat() bf.setAlignment( Qt.AlignLeft if _format == "Left" else Qt.AlignHCenter if _format == "Center" else Qt.AlignRight if _format == "Right" else Qt.AlignJustify) - print(bf.alignment() == Qt.AlignLeft) - cursor.mergeBlockFormat(bf) + cursor.setBlockFormat(bf) self.setTextCursor(cursor) elif self._textFormat == "t2t":