chore: resolve undefined-field

This commit is contained in:
Alexander Courtis
2024-10-28 15:15:23 +11:00
parent 4372e6a217
commit a4a6e6caa3
2 changed files with 10 additions and 8 deletions

View File

@@ -82,8 +82,8 @@ local function path_ignored_in_project(path, project)
end end
if project.files then if project.files then
for file, status in pairs(project.files) do for p, xy in pairs(project.files) do
if status == "!!" and vim.startswith(path, file) then if xy == "!!" and vim.startswith(path, p) then
return true return true
end end
end end
@@ -235,13 +235,13 @@ local function reload_tree_at(toplevel)
end end
M.reload_project(toplevel, nil, function() M.reload_project(toplevel, nil, function()
local git_status = M.get_project(toplevel) local project = M.get_project(toplevel)
Iterator.builder(root_node.nodes) Iterator.builder(root_node.nodes)
:hidden() :hidden()
:applier(function(node) :applier(function(node)
local parent_ignored = node.parent and node.parent:is_git_ignored() or false local parent_ignored = node.parent and node.parent:is_git_ignored() or false
node:update_git_status(parent_ignored, git_status) node:update_git_status(parent_ignored, project)
end) end)
:recursor(function(node) :recursor(function(node)
return node.nodes and #node.nodes > 0 and node.nodes return node.nodes and #node.nodes > 0 and node.nodes
@@ -371,9 +371,9 @@ function M.reload_node_status(dir, projects)
end end
local toplevel = M.get_toplevel(dir.absolute_path) local toplevel = M.get_toplevel(dir.absolute_path)
local status = projects[toplevel] or {} local project = projects[toplevel] or {}
for _, node in ipairs(dir.nodes) do for _, node in ipairs(dir.nodes) do
node:update_git_status(dir:is_git_ignored(), status) node:update_git_status(dir:is_git_ignored(), project)
M.reload_node_status(node:as(DirectoryNode), projects) M.reload_node_status(node:as(DirectoryNode), projects)
end end
end end

View File

@@ -205,8 +205,9 @@ function GitRunner:finalise()
end end
end end
---Return nil when callback present
---@private ---@private
---@return GitPathXY? statuses nil if callback present ---@return GitPathXY?
function GitRunner:execute() function GitRunner:execute()
local async = self.opts.callback ~= nil local async = self.opts.callback ~= nil
local profile = log.profile_start("git %s job %s %s", async and "async" or "sync", self.opts.toplevel, self.opts.path) local profile = log.profile_start("git %s job %s %s", async and "async" or "sync", self.opts.toplevel, self.opts.path)
@@ -238,8 +239,9 @@ function GitRunner:execute()
end end
---Static method to run a git process, which will be killed if it takes more than timeout ---Static method to run a git process, which will be killed if it takes more than timeout
---Return nil when callback present
---@param opts GitRunnerOpts ---@param opts GitRunnerOpts
---@return GitPathXY? statuses nil if callback present ---@return GitPathXY?
function GitRunner:run(opts) function GitRunner:run(opts)
---@type GitRunner ---@type GitRunner
local runner = { local runner = {