Bristol-Braille / canute-ui

User interface for the Canute electronic Braille reader.
http://bristolbraille.co.uk
GNU General Public License v3.0
36 stars 6 forks source link

Bookmarks menu: duplicate "start of book" entries #217

Open zwbrbr opened 5 years ago

zwbrbr commented 5 years ago

...and "end of book". I think this is when user has (needlessly) manually added bookmark at page 1 and/or at page N, and some magic is rendering it differently because UI thinks it's an automatic bookmark.

Low priority for now; doesn't break anything, and there's no need for page 1 or page N bookmarks when there are magic entries.

dupe-bookmarks

The corresponding state:

current_page = 1 bookmarks = [ 1, 2, 3, 4, 5, 8,]

Maybe the mystery is really: how are we inserting a bookmark at page 1 if that's detected and special-cased? It might have happened in fuzz testing.

zwbrbr commented 5 years ago

Dupe start-of-book: while loading, the current page is -1. If you set a bookmark before the book loads (happens pretty often under fuzz testing), you get [-1, 0=magic-start-of-book, 42, 99=magic-end-of-book]. When they're written out the first and last (which are meant to be the magic ones) are trimmed off. When -1 is present before trimming, the naive trimming leaves the magic start-of-book in there. It gets loaded back in with no de-duplication or checking.

Still not sure about how end-of-book dupes come about though. Suspect it may have to do with legitimate penultimate page bookmarks that pre-date form feed handling, in which case it's unlikely to arise in real use. Deduplicate, and warn, when loading bookmarks in.