DocSettings: Fix candidates sorting (#9607)

The candidates array had a very very very high chance of being sparse, which effectively broke the logic.
It was mostly harmless since said logic is only here for a long and varied history of backwards compatibility ;).
This commit is contained in:
NiLuJe
2022-10-09 19:32:35 +02:00
committed by GitHub
parent 718b136c9a
commit c9ff0071e3
4 changed files with 71 additions and 55 deletions

View File

@@ -31,14 +31,14 @@ function LuaDefaults:open(path)
if ok and stored then
new.rw = stored
else
if existing then logger.warn("Failed reading", new.file, "(probably corrupted).") end
if existing then logger.warn("LuaDefaults: Failed reading", new.file, "(probably corrupted).") end
-- Fallback to .old if it exists
ok, stored = pcall(dofile, new.file..".old")
if ok and stored then
if existing then logger.warn("read from backup file", new.file..".old") end
if existing then logger.warn("LuaDefaults: read from backup file", new.file..".old") end
new.rw = stored
else
if existing then logger.warn("no usable backup file for", new.file, "to read from") end
if existing then logger.warn("LuaDefaults: no usable backup file for", new.file, "to read from") end
new.rw = {}
end
end