refactor(#2826): View is an Explorer member

This commit is contained in:
Alexander Courtis
2025-04-21 12:02:19 +10:00
parent 0eb21f66f7
commit 44cb3d2f0a
21 changed files with 170 additions and 114 deletions

View File

@@ -1,5 +1,5 @@
local core = require("nvim-tree.core")
local lib = require("nvim-tree.lib")
local view = require("nvim-tree.view")
local finders_find_file = require("nvim-tree.actions.finders.find-file")
local M = {}
@@ -10,6 +10,8 @@ local M = {}
---@param cwd boolean|nil legacy -> opts.path
---@param bang boolean|nil legacy -> opts.update_root
function M.fn(opts, no_focus, cwd, bang)
local explorer = core.get_explorer()
-- legacy arguments
if type(opts) == "boolean" then
opts = {
@@ -40,9 +42,9 @@ function M.fn(opts, no_focus, cwd, bang)
opts.path = nil
end
if view.View:is_visible() then
if explorer and explorer.view:is_visible() then
-- close
view.View:close()
explorer.view:close()
else
-- open
lib.open({