chore: resolve undefined-field
This commit is contained in:
parent
5c46c9c58a
commit
e82db1c44d
@ -127,51 +127,6 @@ function M.file_status_to_dir_status(status, cwd)
|
|||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
---Git file status for an absolute path with optional fallback
|
|
||||||
---@param parent_ignored boolean
|
|
||||||
---@param status table?
|
|
||||||
---@param path string
|
|
||||||
---@param path_fallback string?
|
|
||||||
---@return GitStatus
|
|
||||||
function M.git_status_file(parent_ignored, status, path, path_fallback)
|
|
||||||
---@type GitStatus
|
|
||||||
local st = {}
|
|
||||||
|
|
||||||
if parent_ignored then
|
|
||||||
st.file = "!!"
|
|
||||||
elseif status and status.files then
|
|
||||||
st.file = status.files[path] or status.files[path_fallback]
|
|
||||||
end
|
|
||||||
|
|
||||||
return st
|
|
||||||
end
|
|
||||||
|
|
||||||
---Git file and directory status for an absolute path with optional file fallback
|
|
||||||
---@param parent_ignored boolean
|
|
||||||
---@param status table?
|
|
||||||
---@param path string
|
|
||||||
---@param path_file string? alternative file path when no other file status
|
|
||||||
---@return GitStatus?
|
|
||||||
function M.git_status_dir(parent_ignored, status, path, path_file)
|
|
||||||
---@type GitStatus?
|
|
||||||
local st
|
|
||||||
|
|
||||||
if parent_ignored then
|
|
||||||
st = {}
|
|
||||||
st.file = "!!"
|
|
||||||
elseif status then
|
|
||||||
st = {}
|
|
||||||
st.file = status.files and (status.files[path] or status.files[path_file])
|
|
||||||
if status.dirs then
|
|
||||||
st.dir = {}
|
|
||||||
st.dir.direct = status.dirs.direct and status.dirs.direct[path]
|
|
||||||
st.dir.indirect = status.dirs.indirect and status.dirs.indirect[path]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return st
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
if opts.git.cygwin_support then
|
if opts.git.cygwin_support then
|
||||||
M.use_cygpath = vim.fn.executable("cygpath") == 1
|
M.use_cygpath = vim.fn.executable("cygpath") == 1
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
local git_utils = require("nvim-tree.git.utils")
|
|
||||||
|
|
||||||
local DirectoryNode = require("nvim-tree.node.directory")
|
local DirectoryNode = require("nvim-tree.node.directory")
|
||||||
|
|
||||||
---@class (exact) DirectoryLinkNode: DirectoryNode
|
---@class (exact) DirectoryLinkNode: DirectoryNode
|
||||||
@ -36,11 +34,24 @@ function DirectoryLinkNode:destroy()
|
|||||||
DirectoryNode.destroy(self)
|
DirectoryNode.destroy(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----Update the directory GitStatus of link target and the file status of the link itself
|
---Update the directory GitStatus of link target and the file status of the link itself
|
||||||
-----@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
-----@param status table|nil
|
---@param status table|nil
|
||||||
function DirectoryLinkNode:update_git_status(parent_ignored, status)
|
function DirectoryLinkNode:update_git_status(parent_ignored, status)
|
||||||
self.git_status = git_utils.git_status_dir(parent_ignored, status, self.link_to, self.absolute_path)
|
if parent_ignored then
|
||||||
|
self.git_status = {}
|
||||||
|
self.git_status.file = "!!"
|
||||||
|
elseif status then
|
||||||
|
self.git_status = {}
|
||||||
|
self.git_status.file = status.files and (status.files[self.link_to] or status.files[self.absolute_path])
|
||||||
|
if status.dirs then
|
||||||
|
self.git_status.dir = {}
|
||||||
|
self.git_status.dir.direct = status.dirs.direct and status.dirs.direct[self.absolute_path]
|
||||||
|
self.git_status.dir.indirect = status.dirs.indirect and status.dirs.indirect[self.absolute_path]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.git_status = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Create a sanitized partial copy of a node, populating children recursively.
|
---Create a sanitized partial copy of a node, populating children recursively.
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
local git_utils = require("nvim-tree.git.utils")
|
|
||||||
|
|
||||||
local Node = require("nvim-tree.node")
|
local Node = require("nvim-tree.node")
|
||||||
|
|
||||||
---@class (exact) DirectoryNode: Node
|
---@class (exact) DirectoryNode: Node
|
||||||
@ -69,7 +67,20 @@ end
|
|||||||
---@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
---@param status table|nil
|
---@param status table|nil
|
||||||
function DirectoryNode:update_git_status(parent_ignored, status)
|
function DirectoryNode:update_git_status(parent_ignored, status)
|
||||||
self.git_status = git_utils.git_status_dir(parent_ignored, status, self.absolute_path, nil)
|
if parent_ignored then
|
||||||
|
self.git_status = {}
|
||||||
|
self.git_status.file = "!!"
|
||||||
|
elseif status then
|
||||||
|
self.git_status = {}
|
||||||
|
self.git_status.file = status.files and status.files[self.absolute_path]
|
||||||
|
if status.dirs then
|
||||||
|
self.git_status.dir = {}
|
||||||
|
self.git_status.dir.direct = status.dirs.direct and status.dirs.direct[self.absolute_path]
|
||||||
|
self.git_status.dir.indirect = status.dirs.indirect and status.dirs.indirect[self.absolute_path]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.git_status = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return string[]? xy short-format statuses
|
---@return string[]? xy short-format statuses
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
local git_utils = require("nvim-tree.git.utils")
|
|
||||||
|
|
||||||
local FileNode = require("nvim-tree.node.file")
|
local FileNode = require("nvim-tree.node.file")
|
||||||
|
|
||||||
---@class (exact) FileLinkNode: FileNode
|
---@class (exact) FileLinkNode: FileNode
|
||||||
@ -32,11 +30,16 @@ function FileLinkNode:destroy()
|
|||||||
FileNode.destroy(self)
|
FileNode.destroy(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----Update the GitStatus of the target otherwise the link itself
|
---Update the GitStatus of the target otherwise the link itself
|
||||||
-----@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
-----@param status table|nil
|
---@param status table|nil
|
||||||
function FileLinkNode:update_git_status(parent_ignored, status)
|
function FileLinkNode:update_git_status(parent_ignored, status)
|
||||||
self.git_status = git_utils.git_status_file(parent_ignored, status, self.link_to, self.absolute_path)
|
self.git_status = {}
|
||||||
|
if parent_ignored then
|
||||||
|
self.git_status.file = "!!"
|
||||||
|
elseif status and status.files then
|
||||||
|
self.git_status.file = status.files[self.link_to] or status.files[self.absolute_path]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Create a sanitized partial copy of a node
|
---Create a sanitized partial copy of a node
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
local git_utils = require("nvim-tree.git.utils")
|
|
||||||
local utils = require("nvim-tree.utils")
|
local utils = require("nvim-tree.utils")
|
||||||
|
|
||||||
local Node = require("nvim-tree.node")
|
local Node = require("nvim-tree.node")
|
||||||
@ -44,7 +43,12 @@ end
|
|||||||
---@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
---@param status table|nil
|
---@param status table|nil
|
||||||
function FileNode:update_git_status(parent_ignored, status)
|
function FileNode:update_git_status(parent_ignored, status)
|
||||||
self.git_status = git_utils.git_status_file(parent_ignored, status, self.absolute_path, nil)
|
self.git_status = {}
|
||||||
|
if parent_ignored then
|
||||||
|
self.git_status.file = "!!"
|
||||||
|
elseif status and status.files then
|
||||||
|
self.git_status.file = status.files[self.absolute_path]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return string[]? xy short-format statuses
|
---@return string[]? xy short-format statuses
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user