From 2e0b2d15736f545e926019009027ae8fb474ad0f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 7 Feb 2021 20:04:26 +0530 Subject: [PATCH] E-book viewer: When jumping to a highlight using the highlights panel, the back button should return to position before jump. Fixes #1914921 [Highlights are not integrated with the navigation history](https://bugs.launchpad.net/calibre/+bug/1914921) --- src/pyj/read_book/view.pyj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 839c418e80..0d2032ab44 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -1075,12 +1075,12 @@ class View: def on_scroll_to_anchor(self, data): self.show_name(data.name, initial_position={'type':'anchor', 'anchor':data.frag, 'replace_history':False}) - def goto_cfi(self, bookpos): + def goto_cfi(self, bookpos, add_to_history): cfiname, internal_cfi = self.parse_cfi(bookpos, self.book) if cfiname and internal_cfi: - # replace_history has to be true here otherwise forward does not - # work after back, as back uses goto_cfi - pos = {'replace_history': True} + # Note that goto_cfi is used by back() so it must not add to + # history by default, otherwise forward() will not work + pos = {'replace_history': not add_to_history} name = cfiname pos.type, pos.cfi = 'cfi', internal_cfi self.show_name(name, initial_position=pos) @@ -1386,4 +1386,4 @@ class View: elif which is 'goto': cfi = self.annotations_manager.cfi_for_highlight(uuid, spine_index) if cfi: - self.goto_cfi(cfi) + self.goto_cfi(cfi, True)