Skip to content

chore: remove TreeExplorer global variable #2561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ function M.purge_all_state()
view.abandon_all_windows()
if core.get_explorer() ~= nil then
git.purge_state()
TreeExplorer = nil
core.reset_explorer()
end
end

Expand Down
6 changes: 5 additions & 1 deletion lua/nvim-tree/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local log = require "nvim-tree.log"

local M = {}

TreeExplorer = nil
local TreeExplorer = nil
local first_init_done = false

function M.init(foldername)
Expand All @@ -27,6 +27,10 @@ function M.get_explorer()
return TreeExplorer
end

function M.reset_explorer()
TreeExplorer = nil
end

function M.get_cwd()
return TreeExplorer and TreeExplorer.absolute_path
end
Expand Down
4 changes: 2 additions & 2 deletions lua/nvim-tree/live-filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local function redraw()
end

local function reset_filter(node_)
node_ = node_ or TreeExplorer
node_ = node_ or require("nvim-tree.core").get_explorer()
Iterator.builder(node_.nodes)
:hidden()
:applier(function(node)
Expand Down Expand Up @@ -79,7 +79,7 @@ function M.apply_filter(node_)
node.hidden = not (has_nodes or (ok and is_match))
end

iterate(node_ or TreeExplorer)
iterate(node_ or require("nvim-tree.core").get_explorer())
end

local function record_char()
Expand Down