Skip to content

Commit

Permalink
fix: sources.manager.dispose* functions not working (#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
AThePeanut4 committed Apr 16, 2024
1 parent 22e566a commit 25bfdbe
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lua/neo-tree/sources/manager.lua
Expand Up @@ -369,7 +369,9 @@ local dispose_state = function(state)
end

M.dispose = function(source_name, tabid)
for i, state in ipairs(all_states) do
-- Iterate in reverse because we are removing items during loop
for i = #all_states, 1, -1 do
local state = all_states[i]
if source_name == nil or state.name == source_name then
if not tabid or tabid == state.tabid then
log.trace(state.name, " disposing of tab: ", tabid)
Expand All @@ -384,7 +386,9 @@ M.dispose_tab = function(tabid)
if not tabid then
error("dispose_tab: tabid cannot be nil")
end
for i, state in ipairs(all_states) do
-- Iterate in reverse because we are removing items during loop
for i = #all_states, 1, -1 do
local state = all_states[i]
if tabid == state.tabid then
log.trace(state.name, " disposing of tab: ", tabid, state.name)
dispose_state(state)
Expand All @@ -410,7 +414,9 @@ M.dispose_window = function(winid)
if not winid then
error("dispose_window: winid cannot be nil")
end
for i, state in ipairs(all_states) do
-- Iterate in reverse because we are removing items during loop
for i = #all_states, 1, -1 do
local state = all_states[i]
if state.id == winid then
log.trace(state.name, " disposing of window: ", winid, state.name)
dispose_state(state)
Expand Down

0 comments on commit 25bfdbe

Please sign in to comment.