Skip to content

Commit 51a8098

Browse files
committed
fix: don't mutate table while iterating
Rel. #492.
1 parent 4005c96 commit 51a8098

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lua/diffview/utils.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,8 @@ M.path_sep = path_sep
13491349
--- @param t table
13501350
--- @return table t
13511351
function M.add_reverse_lookup(t)
1352-
for k, v in pairs(t) do t[v] = k end
1352+
local keys = vim.tbl_keys(t)
1353+
for _, k in ipairs(keys) do t[t[k]] = k end
13531354
return t
13541355
end
13551356

0 commit comments

Comments
 (0)