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

@@ -144,10 +144,16 @@ function M.find_node(nodes, fn)
return node.group_next and { node.group_next } or (node.open and #node.nodes > 0 and node.nodes)
end)
:iterate()
i = require("nvim-tree.view").View:is_root_folder_visible() and i or i - 1
if node and node.explorer.live_filter.filter then
i = i + 1
if node then
if not node.explorer.view:is_root_folder_visible() then
i = i - 1
end
if node.explorer.live_filter.filter then
i = i + 1
end
end
return node, i
end
@@ -497,7 +503,10 @@ function M.focus_file(path)
local _, i = M.find_node(require("nvim-tree.core").get_explorer().nodes, function(node)
return node.absolute_path == path
end)
require("nvim-tree.view").View:set_cursor({ i + 1, 1 })
local explorer = require("nvim-tree.core").get_explorer()
if explorer then
explorer.view:set_cursor({ i + 1, 1 })
end
end
---Focus node passed as parameter if visible, otherwise focus first visible parent.
@@ -517,7 +526,7 @@ function M.focus_node_or_parent(node)
end)
if found_node or node.parent == nil then
require("nvim-tree.view").View:set_cursor({ i + 1, 1 })
explorer.view:set_cursor({ i + 1, 1 })
break
end