diff --git a/src/calibre/gui2/tweak_book/editor/smarts/python.py b/src/calibre/gui2/tweak_book/editor/smarts/python.py index fdf2237427..1a06c3bf8b 100644 --- a/src/calibre/gui2/tweak_book/editor/smarts/python.py +++ b/src/calibre/gui2/tweak_book/editor/smarts/python.py @@ -85,6 +85,7 @@ class Smarts(NullSmarts): elif key == Qt.Key_Home and no_modifiers(ev, Qt.ControlModifier) and not is_cursor_on_wrapped_line(editor): cursor, text = get_text_before_cursor(editor) + cursor = editor.textCursor() mode = cursor.KeepAnchor if test_modifiers(ev, Qt.ShiftModifier) else cursor.MoveAnchor cursor.movePosition(cursor.StartOfBlock, mode) if text.strip():