ReaderBookmark: fix comparing positions (#10109)

reviewable/pr10115/r1
hius07 1 year ago committed by GitHub
parent db9cb542e4
commit 91ff6ce2d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -245,13 +245,19 @@ function ReaderBookmark:isBookmarkInPositionOrder(a, b)
if compare_xp then
if compare_xp == 0 then -- both bookmarks with the same start
if a.highlighted and b.highlighted then -- both are highlights, compare ends
return self.ui.document:compareXPointers(a.pos1, b.pos1) < 0
compare_xp = self.ui.document:compareXPointers(a.pos1, b.pos1)
if compare_xp then
return compare_xp < 0
end
logger.warn("Invalid xpointer in highlight:", a.pos1, b.pos1)
return
end
return a.highlighted -- have page bookmarks before highlights
end
return compare_xp < 0
end
-- if compare_xp is nil, some xpointer is invalid and will be sorted first to page 1
logger.warn("Invalid xpointer in highlight:", a.page, b.page)
end
return a_page > b_page
end

Loading…
Cancel
Save