From d61273b7cdd221e9711e48fdf7d318905dd49433 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 11 Apr 2020 09:47:18 +0530 Subject: [PATCH] When applying a new highlight over a single existing one, replace it --- src/pyj/read_book/iframe.pyj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 74241731bb..c3f7449045 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -664,12 +664,16 @@ class IframeBoss: unwrap_crw(crw) removed_highlights[self.annot_id_uuid_map[crw]] = True v'delete self.annot_id_uuid_map[crw]' + removed_highlights = Object.keys(removed_highlights) + if removed_highlights.length is 1: + data.uuid = removed_highlights[0] + removed_highlights = v'[]' self.send_message( 'annotations', type='highlight-applied', uuid=data.uuid, ok=annot_id is not None, bounds=bounds, - removed_highlights=Object.keys(removed_highlights), + removed_highlights=removed_highlights, highlighted_text=text, ) reset_find_caches()