diff --git a/src/calibre/gui2/tweak_book/editor/widget.py b/src/calibre/gui2/tweak_book/editor/widget.py index b5b2370f80..d07b7027f7 100644 --- a/src/calibre/gui2/tweak_book/editor/widget.py +++ b/src/calibre/gui2/tweak_book/editor/widget.py @@ -384,7 +384,7 @@ class Editor(QMainWindow): a = m.addAction c = self.editor.cursorForPosition(pos) r = self.editor.syntax_range_for_cursor(c) - if r.format.property(SPELL_PROPERTY).toBool(): + if r is not None and r.format.property(SPELL_PROPERTY).toBool(): word = self.editor.text_for_range(c.block(), r) locale = self.editor.spellcheck_locale_for_cursor(c) orig_pos = c.position()