feat: length 1 to 0 bug

This commit is contained in:
Prime Again 2025-02-09 14:50:39 -07:00
parent b924b2cb9e
commit 3b8cf0e1ea
2 changed files with 11 additions and 4 deletions

View File

@ -14,10 +14,7 @@ local function guess_length(arr)
end
local function determine_length(arr, previous_length)
local idx = previous_length
if idx == 1 and arr[idx] == nil then
return 0
end
local idx = 0
for i = previous_length, 1, -1 do
if arr[i] ~= nil then
idx = i

View File

@ -193,6 +193,16 @@ describe("list", function()
}, list.items)
end)
it("remove #653 bug", function()
local config = Config.merge_config()
local c = Config.get_config(config, "foo")
local list = List:new(c, "foo", {
{ value = "one" },
})
list:remove_at(1)
eq(0, list:length())
end)
it("remove_at", function()
local config = Config.merge_config()
local c = Config.get_config(config, "foo")