KVPage: fix crash from empty page due to item deletion (#9974)

Fixes #9972.
reviewable/pr9970/r2
weijiuqiao 1 year ago committed by GitHub
parent 54a105c24f
commit 89af6d9385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -608,6 +608,7 @@ function KeyValuePage:_populateItems()
-- first we check if no unfit item at all
local width_ratio
if (#self.kv_pairs == 0) or
(#key_widths == 0) or
(key_widths[#key_widths] <= key_w and value_widths[#value_widths] <= value_w) then
width_ratio = 1/2
end
@ -747,6 +748,8 @@ end
function KeyValuePage:removeKeyValueItem(kv_item)
if kv_item.kv_pairs_idx then
table.remove(self.kv_pairs, kv_item.kv_pairs_idx)
self.pages = math.ceil(#self.kv_pairs / self.items_per_page)
self.show_page = math.min(self.show_page, self.pages)
self:_populateItems()
end
end

Loading…
Cancel
Save