KeyValuePage: Handle nil/empty kvp arrays (#9705)

reviewable/pr9710/r1
Roygbyte 2 years ago committed by GitHub
parent c740ee3174
commit cf643c453b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -291,6 +291,7 @@ local KeyValuePage = FocusManager:extend{
}
function KeyValuePage:init()
self.kv_pairs = self.kv_pairs or {}
self.dimen = Geom:new{
x = 0,
y = 0,
@ -594,7 +595,8 @@ function KeyValuePage:_populateItems()
local unfit_items_count -- count item that needs to move or truncate key/value, not fit 1/2 ratio
-- first we check if no unfit item at all
local width_ratio
if key_widths[#key_widths] <= key_w and value_widths[#value_widths] <= value_w then
if (#self.kv_pairs == 0) or
(key_widths[#key_widths] <= key_w and value_widths[#value_widths] <= value_w) then
width_ratio = 1/2
end
if not width_ratio then

Loading…
Cancel
Save