From 9499017eb78a39de4e213ccdd40cc64d2232dff6 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 23 Sep 2024 11:30:35 +1000 Subject: [PATCH] destroy nodes, not explorer --- lua/nvim-tree/explorer/init.lua | 12 ------------ lua/nvim-tree/node/directory.lua | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua index ac0b82a0ce3..8f9a1a5924c 100644 --- a/lua/nvim-tree/explorer/init.lua +++ b/lua/nvim-tree/explorer/init.lua @@ -75,18 +75,6 @@ function Explorer:expand(node) self:_load(node) end -function Explorer:destroy() - local function iterate(node) - node:destroy() - if node.nodes then - for _, child in pairs(node.nodes) do - iterate(child) - end - end - end - iterate(self) -end - ---@param node Node ---@param git_status table|nil function Explorer:reload(node, git_status) diff --git a/lua/nvim-tree/node/directory.lua b/lua/nvim-tree/node/directory.lua index bc6a610a5c2..1a14e5636ab 100644 --- a/lua/nvim-tree/node/directory.lua +++ b/lua/nvim-tree/node/directory.lua @@ -49,4 +49,13 @@ function DirectoryNode:create(explorer, parent, absolute_path, name, fs_stat) return o end +function DirectoryNode:destroy() + BaseNode.destroy(self) + if self.nodes then + for _, node in pairs(self.nodes) do + node:destroy() + end + end +end + return DirectoryNode