Skip to content

Commit

Permalink
Thursday 2024-11-28 14:36:05
Browse files Browse the repository at this point in the history
  • Loading branch information
jackokring committed Nov 28, 2024
1 parent a8ba384 commit d6aff14
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lua/doris/novaride.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ local mt = {
__newindex = function(t, k, v)
-- print("*update of element " .. tostring(k) .. " to " .. tostring(v))
if t[index][k] ~= nil then -- false? so has to be explicitly checked
M.restore()
-- lock dep on index outside loop
local i = #index
for _ = 1, i do
M.restore()
end
-- assume stack 2 as __newindex
error("novaride key: " .. tostring(k) .. " of: " .. tostring(t) .. " assigned already", 2)
end
Expand Down Expand Up @@ -62,8 +66,6 @@ end
---every setup (beginning) must have a restore (end)
---@return NovarideModule
M.restore = function()
-- restore the context
_G = M.untrack(_G)
if #index > 0 then
-- restore locale for UI weirdness
os.setlocale(index[#index])
Expand All @@ -72,6 +74,10 @@ M.restore = function()
else
error("setup was not called that many times to restore", 2)
end
if #index == 0 then
-- restore the context at last
_G = M.untrack(_G)
end
return M
end

Expand Down

0 comments on commit d6aff14

Please sign in to comment.