Skip to content

Commit

Permalink
fix: use pairs instead of ipairs to iterate over tabpages (#56)
Browse files Browse the repository at this point in the history
Using Lua's ipairs() to iterate over tabpages is incorrect because
tabpage indices are not guaranteed to be sequential nor start from 1.
Lua's ipairs() stops iterating over integer keys as soon as it
encounters a nil value, which can lead to some tabpages not being
destroyed. Using pairs() ensures that all tabpages are destroyed.
  • Loading branch information
b0o committed Mar 8, 2024
1 parent 4fc2970 commit a3df527
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/incline/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ M.destroy = function()
end
M.update:reset()
util.clear_augroup()
for _, tabpage in ipairs(state.tabpages) do
for _, tabpage in pairs(state.tabpages) do
tabpage:destroy()
end
state.current_tab = nil
Expand Down

0 comments on commit a3df527

Please sign in to comment.