chore: resolve undefined-field
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
local git = require("nvim-tree.git")
|
||||
local git_utils = require("nvim-tree.git.utils")
|
||||
|
||||
local DirectoryNode = require("nvim-tree.node.directory")
|
||||
|
||||
@@ -40,7 +40,7 @@ end
|
||||
-----@param parent_ignored boolean
|
||||
-----@param status table|nil
|
||||
function DirectoryLinkNode:update_git_status(parent_ignored, status)
|
||||
self.git_status = git.git_status_dir(parent_ignored, status, self.link_to, self.absolute_path)
|
||||
self.git_status = git_utils.git_status_dir(parent_ignored, status, self.link_to, self.absolute_path)
|
||||
end
|
||||
|
||||
---Create a sanitized partial copy of a node, populating children recursively.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local git = require("nvim-tree.git")
|
||||
local watch = require("nvim-tree.explorer.watch")
|
||||
local git_utils = require("nvim-tree.git.utils")
|
||||
|
||||
local Node = require("nvim-tree.node")
|
||||
|
||||
@@ -46,7 +45,7 @@ function DirectoryNode:create(explorer, parent, absolute_path, name, fs_stat)
|
||||
}
|
||||
o = self:new(o) --[[@as DirectoryNode]]
|
||||
|
||||
o.watcher = watch.create_watcher(o)
|
||||
o.watcher = require("nvim-tree.explorer.watch").create_watcher(o)
|
||||
|
||||
return o
|
||||
end
|
||||
@@ -70,7 +69,7 @@ end
|
||||
---@param parent_ignored boolean
|
||||
---@param status table|nil
|
||||
function DirectoryNode:update_git_status(parent_ignored, status)
|
||||
self.git_status = git.git_status_dir(parent_ignored, status, self.absolute_path, nil)
|
||||
self.git_status = git_utils.git_status_dir(parent_ignored, status, self.absolute_path, nil)
|
||||
end
|
||||
|
||||
---@return string[]? xy short-format statuses
|
||||
@@ -123,35 +122,6 @@ function DirectoryNode:get_git_status()
|
||||
end
|
||||
end
|
||||
|
||||
---Refresh contents and git status for a single node
|
||||
function DirectoryNode:refresh()
|
||||
local node = self:get_parent_of_group() or self
|
||||
local toplevel = git.get_toplevel(self.absolute_path)
|
||||
|
||||
git.reload_project(toplevel, self.absolute_path, function()
|
||||
local project = git.get_project(toplevel) or {}
|
||||
|
||||
self.explorer:reload(node, project)
|
||||
|
||||
node:update_parent_statuses(project, toplevel)
|
||||
|
||||
self.explorer.renderer:draw()
|
||||
end)
|
||||
end
|
||||
|
||||
---@param projects table
|
||||
function DirectoryNode:reload_node_status(projects)
|
||||
local toplevel = git.get_toplevel(self.absolute_path)
|
||||
local status = projects[toplevel] or {}
|
||||
for _, node in ipairs(self.nodes) do
|
||||
node:update_git_status(self:is_git_ignored(), status)
|
||||
local dir = node:as(DirectoryNode)
|
||||
if dir and #dir.nodes > 0 then
|
||||
dir:reload_node_status(projects)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- If node is grouped, return the last node in the group. Otherwise, return the given node.
|
||||
---@return DirectoryNode
|
||||
function DirectoryNode:last_group_node()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local git = require("nvim-tree.git")
|
||||
local git_utils = require("nvim-tree.git.utils")
|
||||
|
||||
local FileNode = require("nvim-tree.node.file")
|
||||
|
||||
@@ -36,7 +36,7 @@ end
|
||||
-----@param parent_ignored boolean
|
||||
-----@param status table|nil
|
||||
function FileLinkNode:update_git_status(parent_ignored, status)
|
||||
self.git_status = git.git_status_file(parent_ignored, status, self.link_to, self.absolute_path)
|
||||
self.git_status = git_utils.git_status_file(parent_ignored, status, self.link_to, self.absolute_path)
|
||||
end
|
||||
|
||||
---Create a sanitized partial copy of a node
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local git = require("nvim-tree.git")
|
||||
local git_utils = require("nvim-tree.git.utils")
|
||||
local utils = require("nvim-tree.utils")
|
||||
|
||||
local Node = require("nvim-tree.node")
|
||||
@@ -44,7 +44,7 @@ end
|
||||
---@param parent_ignored boolean
|
||||
---@param status table|nil
|
||||
function FileNode:update_git_status(parent_ignored, status)
|
||||
self.git_status = git.git_status_file(parent_ignored, status, self.absolute_path, nil)
|
||||
self.git_status = git_utils.git_status_file(parent_ignored, status, self.absolute_path, nil)
|
||||
end
|
||||
|
||||
---@return string[]? xy short-format statuses
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
local git = require("nvim-tree.git")
|
||||
|
||||
local Class = require("nvim-tree.class")
|
||||
|
||||
---Abstract Node class.
|
||||
@@ -52,38 +50,6 @@ function Node:is_dotfile()
|
||||
return false
|
||||
end
|
||||
|
||||
---@param project table?
|
||||
---@param root string?
|
||||
function Node:update_parent_statuses(project, root)
|
||||
local node = self
|
||||
while project and node do
|
||||
-- step up to the containing project
|
||||
if node.absolute_path == root then
|
||||
-- stop at the top of the tree
|
||||
if not node.parent then
|
||||
break
|
||||
end
|
||||
|
||||
root = git.get_toplevel(node.parent.absolute_path)
|
||||
|
||||
-- stop when no more projects
|
||||
if not root then
|
||||
break
|
||||
end
|
||||
|
||||
-- update the containing project
|
||||
project = git.get_project(root)
|
||||
git.reload_project(root, node.absolute_path, nil)
|
||||
end
|
||||
|
||||
-- update status
|
||||
node:update_git_status(node.parent and node.parent:is_git_ignored() or false, project)
|
||||
|
||||
-- maybe parent
|
||||
node = node.parent
|
||||
end
|
||||
end
|
||||
|
||||
---Get the highest parent of grouped nodes, nil when not grouped
|
||||
---@return DirectoryNode?
|
||||
function Node:get_parent_of_group()
|
||||
|
||||
Reference in New Issue
Block a user