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,14 +1,19 @@
local view = require("nvim-tree.view")
local core = require("nvim-tree.core")
local M = {}
---Resize the tree, persisting the new size.
---@param opts ApiTreeResizeOpts|nil
function M.fn(opts)
local explorer = core.get_explorer()
if not explorer then
return
end
if opts == nil then
-- reset to config values
view.View:configure_width()
view.View:resize()
explorer.view:configure_width()
explorer.view:resize()
return
end
@@ -16,19 +21,19 @@ function M.fn(opts)
local width_cfg = options.width
if width_cfg ~= nil then
view.View:configure_width(width_cfg)
view.View:resize()
explorer.view:configure_width(width_cfg)
explorer.view:resize()
return
end
if not view.View:is_width_determined() then
if not explorer.view:is_width_determined() then
-- {absolute} and {relative} do nothing when {width} is a function.
return
end
local absolute = options.absolute
if type(absolute) == "number" then
view.View:resize(absolute)
explorer.view:resize(absolute)
return
end
@@ -39,7 +44,7 @@ function M.fn(opts)
relative_size = "+" .. relative_size
end
view.View:resize(relative_size)
explorer.view:resize(relative_size)
return
end
end