diff --git a/src/calibre/gui2/tweak_book/editor/syntax/base.py b/src/calibre/gui2/tweak_book/editor/syntax/base.py index 9b404c7ea2..0ba4881935 100644 --- a/src/calibre/gui2/tweak_book/editor/syntax/base.py +++ b/src/calibre/gui2/tweak_book/editor/syntax/base.py @@ -53,6 +53,7 @@ class SyntaxHighlighter(QSyntaxHighlighter): def highlightBlock(self, text): try: state = self.previousBlockState() + self.setCurrentBlockUserData(None) # Ensure that any stale user data is discarded if state == -1: state = 0 state = self.state_class(state)