From 29c8943ebd2a5b55694195e16d657b30d98b6602 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 10 May 2014 15:33:30 +0530 Subject: [PATCH] Edit book: Fix regression that caused an error when trying to edit files with no defined syntax, such as plain .txt files. Fixes #1318139 [Editor: Synatax-Highlighter error](https://bugs.launchpad.net/calibre/+bug/1318139) --- src/calibre/gui2/tweak_book/editor/syntax/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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():