diff --git a/src/calibre/gui2/tweak_book/editor/syntax/base.py b/src/calibre/gui2/tweak_book/editor/syntax/base.py index d2a0400075..909f1ead34 100644 --- a/src/calibre/gui2/tweak_book/editor/syntax/base.py +++ b/src/calibre/gui2/tweak_book/editor/syntax/base.py @@ -107,7 +107,7 @@ class SyntaxHighlighter(object): @pyqtSlot(int, int, int) def reformat_blocks(self, position, removed, added): doc = self.doc - if doc is None: + if doc is None or not hasattr(self, 'state_map'): return last_block = doc.findBlock(position + added + (1 if removed > 0 else 0)) if not last_block.isValid():