Highlights backup fix (#8479)

Fixes opening book with old highlights, when (after deleting the last highlight on a page) empty table of highlights for this page was not deleted.
pull/8481/head
hius07 2 years ago committed by GitHub
parent e9ba854ff0
commit e66b26865b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -792,7 +792,15 @@ function ReaderView:onReadSettings(config)
self.highlight.saved = config:readSetting("highlight", {})
-- Highlight formats in crengine and mupdf are incompatible.
-- Backup highlights when the document is opened with incompatible engine.
local _, page_highlights = next(self.highlight.saved) -- get the first page with highlights
local page, page_highlights
while true do -- remove empty tables for pages without highlights and get the first page with highlights
page, page_highlights = next(self.highlight.saved)
if not page or #page_highlights > 0 then
break -- we're done (there is none, or there is some usable)
else
self.highlight.saved[page] = nil -- clean it up while we're at it, and find another one
end
end
if page_highlights then
local highlight_type = type(page_highlights[1].pos0)
if self.ui.rolling and highlight_type == "table" then

Loading…
Cancel
Save