chore: resolve undefined-field

This commit is contained in:
Alexander Courtis
2024-10-28 15:09:27 +11:00
parent 46725dadb8
commit 4372e6a217
4 changed files with 34 additions and 34 deletions

View File

@@ -8,7 +8,7 @@ local Iterator = require("nvim-tree.iterators.node-iterator")
local DirectoryNode = require("nvim-tree.node.directory")
---Git xy short-format statuses for a single node
---@class (exact) GitStatus
---@class (exact) GitNodeStatus
---@field file string?
---@field dir table<"direct" | "indirect", string[]>?
@@ -135,9 +135,9 @@ function M.reload_project(toplevel, path, callback)
}
if callback then
---@param statuses GitPathXY
runner_opts.callback = function(statuses)
reload_git_project(toplevel, path, project, statuses)
---@param path_xy GitPathXY
runner_opts.callback = function(path_xy)
reload_git_project(toplevel, path, project, path_xy)
callback()
end
GitRunner:run(runner_opts)

View File

@@ -10,11 +10,11 @@ local Class = require("nvim-tree.class")
---@field list_untracked boolean
---@field list_ignored boolean
---@field timeout integer
---@field callback fun(statuses: GitPathXY)?
---@field callback fun(path_xy: GitPathXY)?
---@class (exact) GitRunner: Class
---@field private opts GitRunnerOpts
---@field private statuses GitPathXY
---@field private path_xy GitPathXY
---@field private rc integer? -- -1 indicates timeout
local GitRunner = Class:new()
@@ -34,7 +34,7 @@ function GitRunner:parse_status_output(status, path)
path = path:gsub("/", "\\")
end
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
@@ -218,7 +218,7 @@ function GitRunner:execute()
self:finalise()
self.opts.callback(self.statuses)
self.opts.callback(self.path_xy)
end)
else
-- sync, maybe call back
@@ -230,9 +230,9 @@ function GitRunner:execute()
self:finalise()
if self.opts.callback then
self.opts.callback(self.statuses)
self.opts.callback(self.path_xy)
else
return self.statuses
return self.path_xy
end
end
end
@@ -244,7 +244,7 @@ function GitRunner:run(opts)
---@type GitRunner
local runner = {
opts = opts,
statuses = {},
path_xy = {},
}
runner = GitRunner:new(runner)

View File

@@ -130,49 +130,49 @@ function M.project_files_to_project_dirs(project_files, cwd)
return project_dirs
end
---Git file status for an absolute path with optional fallback
---Git file status for an absolute path
---@param parent_ignored boolean
---@param status table?
---@param path string
---@param path_fallback string?
---@return GitStatus
---@param path_fallback string? alternative file path when no other file status
---@return GitNodeStatus
function M.git_status_file(parent_ignored, status, path, path_fallback)
---@type GitStatus
local st = {}
---@type GitNodeStatus
local ns = {}
if parent_ignored then
st.file = "!!"
ns.file = "!!"
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
return st
return ns
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 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
---@param path_fallback string? alternative file path when no other file status
---@return GitNodeStatus?
function M.git_status_dir(parent_ignored, status, path, path_fallback)
---@type GitNodeStatus?
local ns
if parent_ignored then
st = {}
st.file = "!!"
ns = {}
ns.file = "!!"
elseif status then
st = {}
st.file = status.files and (status.files[path] or status.files[path_file])
ns = {}
ns.file = status.files and (status.files[path] or status.files[path_fallback])
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]
ns.dir = {}
ns.dir.direct = status.dirs.direct and status.dirs.direct[path]
ns.dir.indirect = status.dirs.indirect and status.dirs.indirect[path]
end
end
return st
return ns
end
function M.setup(opts)

View File

@@ -8,7 +8,7 @@ local Class = require("nvim-tree.class")
---@field absolute_path string
---@field executable boolean
---@field fs_stat uv.fs_stat.result?
---@field git_status GitStatus?
---@field git_status GitNodeStatus?
---@field hidden boolean
---@field name string
---@field parent DirectoryNode?