E-book viewer: Fix modifying, then jumping to and then modifying the highlight again from the highlights panel causing the highlight to be deleted. Fixes #2033981 [E-book viewer: highlights get unexpectedly deleted](https://bugs.launchpad.net/calibre/+bug/2033981)

This commit is contained in:
Kovid Goyal 2023-09-04 08:58:10 +05:30
parent 6c7fff344b
commit 8828bc0e61
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 4 deletions

View File

@ -143,7 +143,6 @@ def select_crw(crw):
sel.removeAllRanges() sel.removeAllRanges()
sel.addRange(r) sel.addRange(r)
return True return True
else:
print(f'range-wrapper: {crw} does not exist') print(f'range-wrapper: {crw} does not exist')
return False return False

View File

@ -877,8 +877,12 @@ class IframeBoss:
elif dtype is 'drag-scroll': elif dtype is 'drag-scroll':
self.scroll_to_extend_annotation(data.backwards) self.scroll_to_extend_annotation(data.backwards)
elif dtype is 'edit-highlight': elif dtype is 'edit-highlight':
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid] found_highlight_to_edit = False
if crw_ and select_crw(crw_): for qcrw, quuid in Object.entries(annot_id_uuid_map):
if quuid is data.uuid and select_crw(qcrw):
found_highlight_to_edit = True
break
if found_highlight_to_edit:
self.ensure_selection_visible() self.ensure_selection_visible()
window.setTimeout(def(): window.setTimeout(def():
self.send_message('annotations', type='edit-highlight') self.send_message('annotations', type='edit-highlight')