Skip to content

Commit 8994c1e

Browse files
committed
move lib.get_nodes to Explorer
1 parent 7324fb1 commit 8994c1e

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

lua/nvim-tree/api.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local lib = require("nvim-tree.lib")
21
local core = require("nvim-tree.core")
32
local view = require("nvim-tree.view")
43
local utils = require("nvim-tree.utils")
@@ -147,7 +146,7 @@ end)
147146

148147
Api.tree.change_root_to_parent = wrap_node(actions.root.dir_up.fn)
149148
Api.tree.get_node_under_cursor = wrap_explorer("get_node_at_cursor")
150-
Api.tree.get_nodes = wrap(lib.get_nodes)
149+
Api.tree.get_nodes = wrap_explorer("get_nodes")
151150

152151
---@class ApiTreeFindFileOpts
153152
---@field buf string|number|nil

lua/nvim-tree/explorer/init.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ function Explorer:get_node_at_cursor()
401401
return utils.get_nodes_by_line(self.nodes, core.get_nodes_starting_line())[cursor[1]]
402402
end
403403

404+
---Api.tree.get_nodes
405+
---@return Node
406+
function Explorer:get_nodes()
407+
return self:clone()
408+
end
409+
404410
function Explorer:setup(opts)
405411
config = opts
406412
require("nvim-tree.explorer.watch").setup(opts)

lua/nvim-tree/lib.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ local M = {
1212
target_winid = nil,
1313
}
1414

15-
---Api.tree.get_nodes
16-
---@return Node[]?
17-
function M.get_nodes()
18-
local explorer = core.get_explorer()
19-
return explorer and explorer:clone()
20-
end
21-
2215
function M.set_target_win()
2316
local id = vim.api.nvim_get_current_win()
2417
local tree_id = view.get_winnr()

0 commit comments

Comments
 (0)