chore: resolve undefined-field
This commit is contained in:
@@ -8,7 +8,7 @@ local Iterator = require("nvim-tree.iterators.node-iterator")
|
|||||||
local DirectoryNode = require("nvim-tree.node.directory")
|
local DirectoryNode = require("nvim-tree.node.directory")
|
||||||
|
|
||||||
---Git xy short-format statuses for a single node
|
---Git xy short-format statuses for a single node
|
||||||
---@class (exact) GitStatus
|
---@class (exact) GitNodeStatus
|
||||||
---@field file string?
|
---@field file string?
|
||||||
---@field dir table<"direct" | "indirect", string[]>?
|
---@field dir table<"direct" | "indirect", string[]>?
|
||||||
|
|
||||||
@@ -135,9 +135,9 @@ function M.reload_project(toplevel, path, callback)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if callback then
|
if callback then
|
||||||
---@param statuses GitPathXY
|
---@param path_xy GitPathXY
|
||||||
runner_opts.callback = function(statuses)
|
runner_opts.callback = function(path_xy)
|
||||||
reload_git_project(toplevel, path, project, statuses)
|
reload_git_project(toplevel, path, project, path_xy)
|
||||||
callback()
|
callback()
|
||||||
end
|
end
|
||||||
GitRunner:run(runner_opts)
|
GitRunner:run(runner_opts)
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ local Class = require("nvim-tree.class")
|
|||||||
---@field list_untracked boolean
|
---@field list_untracked boolean
|
||||||
---@field list_ignored boolean
|
---@field list_ignored boolean
|
||||||
---@field timeout integer
|
---@field timeout integer
|
||||||
---@field callback fun(statuses: GitPathXY)?
|
---@field callback fun(path_xy: GitPathXY)?
|
||||||
|
|
||||||
---@class (exact) GitRunner: Class
|
---@class (exact) GitRunner: Class
|
||||||
---@field private opts GitRunnerOpts
|
---@field private opts GitRunnerOpts
|
||||||
---@field private statuses GitPathXY
|
---@field private path_xy GitPathXY
|
||||||
---@field private rc integer? -- -1 indicates timeout
|
---@field private rc integer? -- -1 indicates timeout
|
||||||
local GitRunner = Class:new()
|
local GitRunner = Class:new()
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ function GitRunner:parse_status_output(status, path)
|
|||||||
path = path:gsub("/", "\\")
|
path = path:gsub("/", "\\")
|
||||||
end
|
end
|
||||||
if #status > 0 and #path > 0 then
|
if #status > 0 and #path > 0 then
|
||||||
self.statuses[utils.path_remove_trailing(utils.path_join({ self.opts.toplevel, path }))] = status
|
self.path_xy[utils.path_remove_trailing(utils.path_join({ self.opts.toplevel, path }))] = status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ function GitRunner:execute()
|
|||||||
|
|
||||||
self:finalise()
|
self:finalise()
|
||||||
|
|
||||||
self.opts.callback(self.statuses)
|
self.opts.callback(self.path_xy)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
-- sync, maybe call back
|
-- sync, maybe call back
|
||||||
@@ -230,9 +230,9 @@ function GitRunner:execute()
|
|||||||
self:finalise()
|
self:finalise()
|
||||||
|
|
||||||
if self.opts.callback then
|
if self.opts.callback then
|
||||||
self.opts.callback(self.statuses)
|
self.opts.callback(self.path_xy)
|
||||||
else
|
else
|
||||||
return self.statuses
|
return self.path_xy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -244,7 +244,7 @@ function GitRunner:run(opts)
|
|||||||
---@type GitRunner
|
---@type GitRunner
|
||||||
local runner = {
|
local runner = {
|
||||||
opts = opts,
|
opts = opts,
|
||||||
statuses = {},
|
path_xy = {},
|
||||||
}
|
}
|
||||||
runner = GitRunner:new(runner)
|
runner = GitRunner:new(runner)
|
||||||
|
|
||||||
|
|||||||
@@ -130,49 +130,49 @@ function M.project_files_to_project_dirs(project_files, cwd)
|
|||||||
return project_dirs
|
return project_dirs
|
||||||
end
|
end
|
||||||
|
|
||||||
---Git file status for an absolute path with optional fallback
|
---Git file status for an absolute path
|
||||||
---@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
---@param status table?
|
---@param status table?
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param path_fallback string?
|
---@param path_fallback string? alternative file path when no other file status
|
||||||
---@return GitStatus
|
---@return GitNodeStatus
|
||||||
function M.git_status_file(parent_ignored, status, path, path_fallback)
|
function M.git_status_file(parent_ignored, status, path, path_fallback)
|
||||||
---@type GitStatus
|
---@type GitNodeStatus
|
||||||
local st = {}
|
local ns = {}
|
||||||
|
|
||||||
if parent_ignored then
|
if parent_ignored then
|
||||||
st.file = "!!"
|
ns.file = "!!"
|
||||||
elseif status and status.files then
|
elseif status and status.files then
|
||||||
st.file = status.files[path] or status.files[path_fallback]
|
ns.file = status.files[path] or status.files[path_fallback]
|
||||||
end
|
end
|
||||||
|
|
||||||
return st
|
return ns
|
||||||
end
|
end
|
||||||
|
|
||||||
---Git file and directory status for an absolute path with optional file fallback
|
---Git file and directory status for an absolute path
|
||||||
---@param parent_ignored boolean
|
---@param parent_ignored boolean
|
||||||
---@param status table?
|
---@param status table?
|
||||||
---@param path string
|
---@param path string
|
||||||
---@param path_file string? alternative file path when no other file status
|
---@param path_fallback string? alternative file path when no other file status
|
||||||
---@return GitStatus?
|
---@return GitNodeStatus?
|
||||||
function M.git_status_dir(parent_ignored, status, path, path_file)
|
function M.git_status_dir(parent_ignored, status, path, path_fallback)
|
||||||
---@type GitStatus?
|
---@type GitNodeStatus?
|
||||||
local st
|
local ns
|
||||||
|
|
||||||
if parent_ignored then
|
if parent_ignored then
|
||||||
st = {}
|
ns = {}
|
||||||
st.file = "!!"
|
ns.file = "!!"
|
||||||
elseif status then
|
elseif status then
|
||||||
st = {}
|
ns = {}
|
||||||
st.file = status.files and (status.files[path] or status.files[path_file])
|
ns.file = status.files and (status.files[path] or status.files[path_fallback])
|
||||||
if status.dirs then
|
if status.dirs then
|
||||||
st.dir = {}
|
ns.dir = {}
|
||||||
st.dir.direct = status.dirs.direct and status.dirs.direct[path]
|
ns.dir.direct = status.dirs.direct and status.dirs.direct[path]
|
||||||
st.dir.indirect = status.dirs.indirect and status.dirs.indirect[path]
|
ns.dir.indirect = status.dirs.indirect and status.dirs.indirect[path]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return st
|
return ns
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local Class = require("nvim-tree.class")
|
|||||||
---@field absolute_path string
|
---@field absolute_path string
|
||||||
---@field executable boolean
|
---@field executable boolean
|
||||||
---@field fs_stat uv.fs_stat.result?
|
---@field fs_stat uv.fs_stat.result?
|
||||||
---@field git_status GitStatus?
|
---@field git_status GitNodeStatus?
|
||||||
---@field hidden boolean
|
---@field hidden boolean
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field parent DirectoryNode?
|
---@field parent DirectoryNode?
|
||||||
|
|||||||
Reference in New Issue
Block a user