From 09312b65b27122f6c087fdabfa597a4db6038751 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 8 Nov 2013 15:38:10 +0530 Subject: [PATCH] Dont set cursor pos beyond end of text when replacing text --- src/calibre/gui2/tweak_book/editor/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index 39845d15d1..2c1980be34 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -122,7 +122,7 @@ class TextEdit(QPlainTextEdit): c.select(c.Document) c.insertText(text) c.endEditBlock() - c.setPosition(pos) + c.setPosition(min(pos, len(text))) self.setTextCursor(c) self.ensureCursorVisible()