* add todo * refactor(#2886): multi instance: node class refactoring: extract links, *_git_status (#2944) * extract DirectoryLinkNode and FileLinkNode, move Node methods to children * temporarily move DirectoryNode methods into BaseNode for easier reviewing * move mostly unchanged DirectoryNode methods back to BaseNode * tidy * git.git_status_file takes an array * update git status of links * luacheck hack * safer git_status_dir * refactor(#2886): multi instance: node class refactoring: DirectoryNode:expand_or_collapse (#2957) move expand_or_collapse to DirectoryNode * refactor(#2886): multi instance: node group functions refactoring (#2959) * move last_group_node to DirectoryNode * move add BaseNode:as and more doc * revert parameter name changes * revert parameter name changes * add Class * move group methods into DN * tidy group methods * tidy group methods * tidy group methods * tidy group methods * parent is DirectoryNode * tidy expand all * BaseNode -> Node * move watcher to DirectoryNode * last_group_node is DirectoryNode only * simplify create-file * simplify parent * simplify collapse-all * simplify live-filter * style * more type safety
This commit is contained in:
committed by
GitHub
parent
63c7ad9037
commit
68be6df2fc
@@ -1,14 +1,15 @@
|
||||
local git = require("nvim-tree.git")
|
||||
local utils = require("nvim-tree.utils")
|
||||
|
||||
local BaseNode = require("nvim-tree.node")
|
||||
local Node = require("nvim-tree.node")
|
||||
|
||||
---@class (exact) FileNode: BaseNode
|
||||
---@class (exact) FileNode: Node
|
||||
---@field extension string
|
||||
local FileNode = BaseNode:new()
|
||||
local FileNode = Node:new()
|
||||
|
||||
---Static factory method
|
||||
---@param explorer Explorer
|
||||
---@param parent Node
|
||||
---@param parent DirectoryNode
|
||||
---@param absolute_path string
|
||||
---@param name string
|
||||
---@param fs_stat uv.fs_stat.result?
|
||||
@@ -26,7 +27,6 @@ function FileNode:create(explorer, parent, absolute_path, name, fs_stat)
|
||||
is_dot = false,
|
||||
name = name,
|
||||
parent = parent,
|
||||
watcher = nil,
|
||||
diag_status = nil,
|
||||
|
||||
extension = string.match(name, ".?[^.]+%.(.*)") or "",
|
||||
@@ -36,10 +36,26 @@ function FileNode:create(explorer, parent, absolute_path, name, fs_stat)
|
||||
return o
|
||||
end
|
||||
|
||||
---Create a sanitized partial copy of a node, populating children recursively.
|
||||
---Update the GitStatus of the file
|
||||
---@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)
|
||||
end
|
||||
|
||||
---@return GitStatus|nil
|
||||
function FileNode:get_git_status()
|
||||
if not self.git_status then
|
||||
return nil
|
||||
end
|
||||
|
||||
return self.git_status.file and { self.git_status.file }
|
||||
end
|
||||
|
||||
---Create a sanitized partial copy of a node
|
||||
---@return FileNode cloned
|
||||
function FileNode:clone()
|
||||
local clone = BaseNode.clone(self) --[[@as FileNode]]
|
||||
local clone = Node.clone(self) --[[@as FileNode]]
|
||||
|
||||
clone.extension = self.extension
|
||||
|
||||
|
||||
Reference in New Issue
Block a user