Skip to content

Commit d4dc784

Browse files
mrbjarksencseickel
authored andcommitted
fix(queue): don't go to next node if it has been removed
1 parent 65fb5e4 commit d4dc784

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lua/neo-tree/events/queue.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ function Queue:for_each(func)
7171
local node = self._list.head
7272
while node ~= nil do
7373
local result = func(node.value)
74+
local node_is_next = false
7475
if result then
7576
if type(result) == "boolean" then
7677
local node_to_remove = node
7778
node = node.next
79+
node_is_next = true
7880
self._list:remove_node(node_to_remove)
7981
elseif type(result) == "table" then
8082
if type(result.handled) == "boolean" and result.handled == true then
@@ -88,8 +90,8 @@ function Queue:for_each(func)
8890
return result
8991
end
9092
end
91-
node = node.next
92-
else
93+
end
94+
if not node_is_next then
9395
node = node.next
9496
end
9597
end

0 commit comments

Comments
 (0)