Implement compacting
This commit is contained in:
@@ -42,6 +42,15 @@ function shared.Noter.Init()
|
||||
|
||||
return ret
|
||||
end
|
||||
---@param array any[]
|
||||
---@return any[]
|
||||
local function Compact(array)
|
||||
local compacted = {}
|
||||
for _, v in pairs(array) do
|
||||
compacted[#compacted + 1] = v
|
||||
end
|
||||
return compacted
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@param args string[]
|
||||
@@ -76,6 +85,9 @@ function shared.Noter.Init()
|
||||
print(string.format("[%s] Deleting note range %s to %s for: %s", ModuleName, start, finish, name))
|
||||
end
|
||||
|
||||
-- Here, because we are deleting random notes, we lose the "iterative" index property
|
||||
-- Ie it's not longer 1..100, it might be 1..47, 50, 68..100
|
||||
-- Which means that we cannot use ipairs, bad!
|
||||
for i = start, finish do
|
||||
if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end
|
||||
if not Heimdall_Data.config.notes[name][i] then
|
||||
@@ -90,6 +102,7 @@ function shared.Noter.Init()
|
||||
Heimdall_Data.config.notes[name][i] = nil
|
||||
end
|
||||
end
|
||||
Heimdall_Data.config.notes[name] = Compact(Heimdall_Data.config.notes[name])
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user