mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(git): always check parents for git root to fix an issue with git submodules. Closes #2143
This commit is contained in:
parent
6c87fde975
commit
14dd362d5d
1 changed files with 6 additions and 14 deletions
|
|
@ -29,24 +29,16 @@ end
|
|||
function M.get_root(path)
|
||||
path = path or 0
|
||||
path = type(path) == "number" and vim.api.nvim_buf_get_name(path) or path --[[@as string]]
|
||||
path = svim.fs.normalize(path)
|
||||
path = path == "" and (vim.uv or vim.loop).cwd() or path
|
||||
path = svim.fs.normalize(path)
|
||||
|
||||
if is_git_root(path) then
|
||||
return path
|
||||
end
|
||||
|
||||
local todo = { path } ---@type string[]
|
||||
for dir in vim.fs.parents(path) do
|
||||
table.insert(todo, dir)
|
||||
end
|
||||
|
||||
-- check cache first
|
||||
for _, dir in ipairs(todo) do
|
||||
if git_cache[dir] then
|
||||
return svim.fs.normalize(dir) or nil
|
||||
end
|
||||
end
|
||||
|
||||
for _, dir in ipairs(todo) do
|
||||
if is_git_root(dir) then
|
||||
return svim.fs.normalize(dir) or nil
|
||||
return svim.fs.normalize(dir)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue