Skip to content

Commit 71e36bb

Browse files
authored
fix: ignore errors from failed redraw due to window being closed (#1110)
1 parent cac2e1b commit 71e36bb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lua/neo-tree/ui/renderer.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,15 @@ M.position = {
677677
M.redraw = function(state)
678678
if state.tree and M.tree_is_visible(state) then
679679
log.trace("Redrawing tree", state.name, state.id)
680-
render_tree(state)
681-
log.trace(" Redrawing tree done", state.name, state.id)
680+
-- every now and then this will fail because the window was closed in
681+
-- betweeen the start of an async refresh and the redraw call.
682+
-- This is not a problem, so we just ignore the error.
683+
local success = pcall(render_tree, state)
684+
if success then
685+
log.trace(" Redrawing tree done", state.name, state.id)
686+
else
687+
log.trace(" Redrawing tree failed, maybe it was closed?", state.name, state.id)
688+
end
682689
end
683690
end
684691
---Visit all nodes ina tree recursively and reduce to a single value.

0 commit comments

Comments
 (0)