z_mirror/CursorEnhancements

git clone https://git.raiguard.me/z_mirror/CursorEnhancements

Caleb HeuerClear item history on configuration changed and harden against crash55b779d

trunk
610 B30 linesraw
1local migrations = {
2  ["2.0.0"] = function()
3    storage.built_item = {}
4    storage.last_item = {}
5  end,
6  ["2.2.0"] = function()
7    storage.subgroups = nil
8  end,
9  ["2.3.0"] = function()
10    storage.last_item = nil
11  end,
12}
13
14--- @type event_handler
15local M = {}
16
17function M.on_configuration_changed(e)
18  local old_version = e.mod_changes[script.mod_name] and e.mod_changes[script.mod_name].old_version
19  if not old_version then
20    return
21  end
22
23  for version, migration in pairs(migrations) do
24    if helpers.compare_versions(old_version, version) < 0 then
25      migration()
26    end
27  end
28end
29
30return M