From 1471322f499f82b3140a14af1157e62c415c3a7b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 29 Apr 2021 06:49:03 +0530 Subject: [PATCH] E-book viewer: The quick highlight button should replace the style of an existing highlight, when one is selected. Fixes #1926518 [[Viewer] Quick highlighting a already highlighted text should replace the original highlighting](https://bugs.launchpad.net/calibre/+bug/1926518) --- src/pyj/read_book/selection_bar.pyj | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pyj/read_book/selection_bar.pyj b/src/pyj/read_book/selection_bar.pyj index f386ef5b8a..d900362096 100644 --- a/src/pyj/read_book/selection_bar.pyj +++ b/src/pyj/read_book/selection_bar.pyj @@ -1027,12 +1027,16 @@ class SelectionBar: cs = self.view.currently_showing.selection if cs.text: if cs.annot_id: - self.create_highlight() + am = self.annotations_manager + self.current_notes = am.notes_for_highlight(cs.annot_id) or '' + self.send_message( + 'apply-highlight', style=self.current_highlight_style.style, uuid=short_uuid(), existing=cs.annot_id, has_notes=v'!!self.current_notes' + ) else: self.current_notes = '' self.send_message('apply-highlight', style=self.current_highlight_style.style, uuid=short_uuid(), has_notes=False) - self.state = WAITING - self.update_position() + self.state = WAITING + self.update_position() def quick_highlight_with_style(self, hs): self.current_highlight_style = hs