diff --git a/frontend/ui/widget/filechooser.lua b/frontend/ui/widget/filechooser.lua index 373e6fc9d..e6fcaebf3 100644 --- a/frontend/ui/widget/filechooser.lua +++ b/frontend/ui/widget/filechooser.lua @@ -158,7 +158,7 @@ local FileChooser = Menu:extend{ return function(a, b) if a.opened == b.opened then if a.opened then - return a.percent_finished < b.percent_finished + return a.sort_percent < b.sort_percent end return ffiUtil.strcoll(a.text, b.text) end @@ -172,7 +172,11 @@ local FileChooser = Menu:extend{ local doc_settings = DocSettings:open(item.path) percent_finished = doc_settings:readSetting("percent_finished") end - item.percent_finished = percent_finished or 0 + + percent_finished = percent_finished or 0 + -- smooth 2 decimal points (0.00) instead of 16 decimal points + item.sort_percent = util.round_decimal(percent_finished, 2) + item.percent_finished = percent_finished end, mandatory_func = function(item) return item.opened and string.format("%d %%", 100 * item.percent_finished) or "–" @@ -186,7 +190,7 @@ local FileChooser = Menu:extend{ return function(a, b) if a.opened == b.opened then if a.opened then - return a.percent_finished < b.percent_finished + return a.sort_percent < b.sort_percent end return ffiUtil.strcoll(a.text, b.text) end @@ -200,7 +204,11 @@ local FileChooser = Menu:extend{ local doc_settings = DocSettings:open(item.path) percent_finished = doc_settings:readSetting("percent_finished") end - item.percent_finished = percent_finished or 0 + + percent_finished = percent_finished or 0 + -- smooth 2 decimal points (0.00) instead of 16 decimal points + item.sort_percent = util.round_decimal(percent_finished, 2) + item.percent_finished = percent_finished end, mandatory_func = function(item) return item.opened and string.format("%d %%", 100 * item.percent_finished) or "–" @@ -245,7 +253,7 @@ local FileChooser = Menu:extend{ percent_finished = doc_settings:readSetting("percent_finished") end - -- smooth 2 decimal points (0.00) instead of 16 decimal numbers + -- smooth 2 decimal points (0.00) instead of 16 decimal points item.sort_percent = sort_percent or util.round_decimal(percent_finished or -1, 2) item.percent_finished = percent_finished or 0 end,