From d28c4b5358bebff2d55b6892fe457fc5c617037d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 10 Dec 2013 21:59:43 +0530 Subject: [PATCH] Handle case when col number moves cursor more than one line past the originating line --- src/calibre/gui2/tweak_book/editor/text.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index c4d5c18383..605ccd10e2 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -198,7 +198,8 @@ class TextEdit(QPlainTextEdit): else: c.setPosition(c.block().position() + col) if c.blockNumber() + 1 > lnum: - c.movePosition(c.PreviousBlock) + # We have moved past the end of the line + c.setPosition(c.block().position()) c.movePosition(c.EndOfBlock) self.setTextCursor(c) self.ensureCursorVisible()