From fd7cbbe4642ff3cdf3eebb70eacbe3d1b10244a3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 11 Nov 2013 17:50:58 +0530 Subject: [PATCH] ... --- src/calibre/gui2/tweak_book/editor/text.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index 35bc7d6259..f1c4c7202d 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -142,11 +142,14 @@ class TextEdit(QPlainTextEdit): sel = QTextEdit.ExtraSelection() sel.format.setBackground(self.highlight_color) sel.cursor = self.textCursor() - self.current_search_mark = sel + if sel.cursor.hasSelection(): + self.current_search_mark = sel + c = self.textCursor() + c.clearSelection() + self.setTextCursor(c) + else: + self.current_search_mark = None self.update_extra_selections() - c = self.textCursor() - c.clearSelection() - self.setTextCursor(c) # Line numbers and cursor line {{{ def highlight_cursor_line(self):