move lib.get_node_at_cursor to Explorer

This commit is contained in:
Alexander Courtis
2024-10-21 11:34:10 +11:00
parent 0992969dc5
commit 7324fb1bf0
11 changed files with 88 additions and 87 deletions

View File

@@ -1,6 +1,5 @@
local view = require("nvim-tree.view")
local core = require("nvim-tree.core")
local utils = require("nvim-tree.utils")
local events = require("nvim-tree.events")
local notify = require("nvim-tree.notify")
@@ -13,25 +12,6 @@ local M = {
target_winid = nil,
}
---@return Node|nil
function M.get_node_at_cursor()
local explorer = core.get_explorer()
if not explorer then
return
end
local cursor = explorer:get_cursor_position()
if not cursor then
return
end
if cursor[1] == 1 and view.is_root_folder_visible(core.get_cwd()) then
return explorer
end
return utils.get_nodes_by_line(explorer.nodes, core.get_nodes_starting_line())[cursor[1]]
end
---Api.tree.get_nodes
---@return Node[]?
function M.get_nodes()