* fix(#1931): do not execute git status in git ignored directories * fix(#1931): reload.refresh_node is always asynchronous
This commit is contained in:
committed by
GitHub
parent
3b62c6bf2c
commit
273c1700eb
@@ -37,6 +37,25 @@ local function reload_git_status(project_root, path, project, git_status)
|
||||
project.dirs = git_utils.file_status_to_dir_status(project.files, project_root)
|
||||
end
|
||||
|
||||
--- Is this path in a known ignored directory?
|
||||
--- @param path string
|
||||
--- @param project table git status
|
||||
--- @return boolean
|
||||
local function path_ignored_in_project(path, project)
|
||||
if not path or not project then
|
||||
return false
|
||||
end
|
||||
|
||||
if project and project.files then
|
||||
for file, status in pairs(project.files) do
|
||||
if status == "!!" and vim.startswith(path, file) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function M.reload()
|
||||
if not M.config.git.enable then
|
||||
return {}
|
||||
@@ -58,7 +77,7 @@ function M.reload_project(project_root, path, callback)
|
||||
return
|
||||
end
|
||||
|
||||
if path and path:find(project_root, 1, true) ~= 1 then
|
||||
if path and (path:find(project_root, 1, true) ~= 1 or path_ignored_in_project(path, project)) then
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
@@ -107,6 +126,14 @@ function M.get_project_root(cwd)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- short-circuit any known ignored paths
|
||||
for root, project in pairs(M.projects) do
|
||||
if project and path_ignored_in_project(cwd, project) then
|
||||
M.cwd_to_project_root[cwd] = root
|
||||
return root
|
||||
end
|
||||
end
|
||||
|
||||
local toplevel = git_utils.get_toplevel(cwd)
|
||||
for _, disabled_for_dir in ipairs(M.config.git.disable_for_dirs) do
|
||||
local toplevel_norm = vim.fn.fnamemodify(toplevel, ":p")
|
||||
|
||||
Reference in New Issue
Block a user