diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua index 6f57fac35..f6eb355f5 100644 --- a/frontend/apps/reader/modules/readerlink.lua +++ b/frontend/apps/reader/modules/readerlink.lua @@ -209,13 +209,15 @@ function ReaderLink:addCurrentLocationToStack() end --- Goes to link. -function ReaderLink:onGotoLink(link) +function ReaderLink:onGotoLink(link, neglect_current_location) logger.dbg("onGotoLink:", link) if self.ui.document.info.has_pages then -- internal pdf links have a "page" attribute, while external ones have an "uri" attribute if link.page then -- Internal link logger.dbg("Internal link:", link) - self:addCurrentLocationToStack() + if not neglect_current_location then + self:addCurrentLocationToStack() + end self.ui:handleEvent(Event:new("GotoPage", link.page + 1)) return true end @@ -229,7 +231,9 @@ function ReaderLink:onGotoLink(link) -- which accepts both of the above legitimate xpointer as input. if self.ui.document:isXPointerInDocument(link) then logger.dbg("Internal link:", link) - self:addCurrentLocationToStack() + if not neglect_current_location then + self:addCurrentLocationToStack() + end self.ui:handleEvent(Event:new("GotoXPointer", link)) return true end diff --git a/frontend/apps/reader/modules/readersearch.lua b/frontend/apps/reader/modules/readersearch.lua index d93052c55..48b6d8576 100644 --- a/frontend/apps/reader/modules/readersearch.lua +++ b/frontend/apps/reader/modules/readersearch.lua @@ -28,16 +28,19 @@ function ReaderSearch:addToMainMenu(menu_items) end function ReaderSearch:onShowSearchDialog(text) + local neglect_current_location = false local do_search = function(search_func, _text, param) return function() local res = search_func(self, _text, param) if res then if self.ui.document.info.has_pages then - self.ui.link:onGotoLink({page = res.page - 1}) + self.ui.link:onGotoLink({page = res.page - 1}, neglect_current_location) self.view.highlight.temp[res.page] = res else - self.ui.link:onGotoLink(res[1].start) + self.ui.link:onGotoLink(res[1].start, neglect_current_location) end + -- Don't add result pages to location ("Go back") stack + neglect_current_location = true end end end