* refactor(#2942): multi instance: move find_node_line to Explorer * refactor(#2942): multi instance: move get_node_from_path to Explorer * refactor(#2942): multi instance: move focus_file to Explorer * refactor(#2942): multi instance: move focus_node_or_parent to Explorer * refactor(#2942): multi instance: move get_node_from_path to Explorer * refactor(#2942): multi instance: move find_node to Explorer * refactor(#2942): multi instance: move get_nodes_by_line to Explorer * refactor(#2942): multi instance: remove unnecessary focus_file * refactor(#2942): style
This commit is contained in:
committed by
GitHub
parent
f92cc3a91c
commit
e179ad2f83
@@ -32,7 +32,7 @@ function M.fn(path)
|
||||
local profile = log.profile_start("find file %s", path_real)
|
||||
|
||||
-- refresh the contents of all parents, expanding groups as needed
|
||||
if utils.get_node_from_path(path_real) == nil then
|
||||
if explorer:get_node_from_path(path_real) == nil then
|
||||
explorer:refresh_parent_nodes_for_path(vim.fn.fnamemodify(path_real, ":h"))
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local utils = require("nvim-tree.utils")
|
||||
local view = require("nvim-tree.view")
|
||||
local core = require("nvim-tree.core")
|
||||
local diagnostics = require("nvim-tree.diagnostics")
|
||||
@@ -36,7 +35,7 @@ end
|
||||
---@param skip_gitignored boolean? default false
|
||||
local function move(explorer, where, what, skip_gitignored)
|
||||
local first_node_line = core.get_nodes_starting_line()
|
||||
local nodes_by_line = utils.get_nodes_by_line(explorer.nodes, first_node_line)
|
||||
local nodes_by_line = explorer:get_nodes_by_line(first_node_line)
|
||||
local iter_start, iter_end, iter_step, cur, first, nex
|
||||
|
||||
local cursor = explorer:get_cursor_position()
|
||||
@@ -191,7 +190,7 @@ local function move_prev_recursive(explorer, what, skip_gitignored)
|
||||
if node_init.name == ".." then -- root node
|
||||
view.set_cursor({ 1, 0 }) -- move to root node (position 1)
|
||||
else
|
||||
local node_init_line = utils.find_node_line(node_init)
|
||||
local node_init_line = explorer:find_node_line(node_init)
|
||||
if node_init_line < 0 then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
local view = require("nvim-tree.view")
|
||||
local utils = require("nvim-tree.utils")
|
||||
|
||||
local DirectoryNode = require("nvim-tree.node.directory")
|
||||
|
||||
local M = {}
|
||||
@@ -29,7 +27,7 @@ function M.fn(should_close)
|
||||
return
|
||||
end
|
||||
|
||||
local _, line = utils.find_node(parent.explorer.nodes, function(n)
|
||||
local _, line = parent.explorer:find_node(function(n)
|
||||
return n.absolute_path == parent.absolute_path
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local utils = require("nvim-tree.utils")
|
||||
local core = require("nvim-tree.core")
|
||||
local Iterator = require("nvim-tree.iterators.node-iterator")
|
||||
|
||||
@@ -12,9 +11,14 @@ function M.fn(direction)
|
||||
return
|
||||
end
|
||||
|
||||
local explorer = core.get_explorer()
|
||||
if not explorer then
|
||||
return
|
||||
end
|
||||
|
||||
local first, last, next, prev = nil, nil, nil, nil
|
||||
local found = false
|
||||
local parent = node.parent or core.get_explorer()
|
||||
local parent = node.parent or explorer
|
||||
Iterator.builder(parent and parent.nodes or {})
|
||||
:recursor(function()
|
||||
return nil
|
||||
@@ -45,7 +49,7 @@ function M.fn(direction)
|
||||
end
|
||||
|
||||
if target_node then
|
||||
utils.focus_file(target_node.absolute_path)
|
||||
explorer:focus_node_or_parent(target_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ local function collapse(node, opts)
|
||||
:iterate()
|
||||
|
||||
explorer.renderer:draw()
|
||||
utils.focus_node_or_parent(node_at_cursor)
|
||||
explorer:focus_node_or_parent(node_at_cursor)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user