diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index 995e61812..a5e93ecbc 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -2224,14 +2224,27 @@ function ReaderHighlight:updateHighlightPageNumbers() local bookmark = bookmarks[i] if bookmark.highlighted then local highlight = self:getHighlightByDatetime(bookmark.datetime) + if not highlight and (self.ui.rolling or bookmark.pos0.page == bookmark.pos1.page) then + -- restore highlight for orphaned bookmark + -- do not bother with restoring pboxes for pdf multi-page highlight, keep bookmark orphaned + highlight = { + datetime = bookmark.datetime, + text = bookmark.notes, + chapter = bookmark.chapter, + pos0 = bookmark.pos0, + pos1 = bookmark.pos1, + drawer = self.view.highlight.saved_drawer, + } + if self.ui.paging then + highlight.pboxes = self.document:getPageBoxesFromPositions(bookmark.page, bookmark.pos0, bookmark.pos1) + end + end if highlight then local pageno = self.ui.paging and bookmark.page or self.document:getPageFromXPointer(bookmark.page) if highlights[pageno] == nil then highlights[pageno] = {} end table.insert(highlights[pageno], highlight) - else -- orphan - table.remove(bookmarks, i) end end end