refactor(git): gitlog as gitlog:// URI singleton, fix synthetic-URI cwd resolve
This commit is contained in:
+5
-4
@@ -84,14 +84,15 @@ function M.resolve(path)
|
||||
return vim.fs.normalize(gitdir), worktree
|
||||
end
|
||||
|
||||
---Resolve the gitdir/worktree from the current buffer's file path, falling
|
||||
---back to `vim.fn.getcwd()` when the buffer is unnamed. Returns nil for
|
||||
---both when not inside a git repo.
|
||||
---Resolve the gitdir/worktree from the current buffer's file path,
|
||||
---falling back to `vim.fn.getcwd()` when the buffer is unnamed or
|
||||
---carries a synthetic URI (`git://`, `gitlog://`) that isn't a real
|
||||
---filesystem path. Returns nil for both when not inside a git repo.
|
||||
---@return string? gitdir
|
||||
---@return string? worktree
|
||||
function M.resolve_cwd()
|
||||
local path = vim.api.nvim_buf_get_name(0)
|
||||
if path == "" then
|
||||
if path == "" or path:match("^%a+://") then
|
||||
path = vim.fn.getcwd()
|
||||
end
|
||||
return M.resolve(path)
|
||||
|
||||
Reference in New Issue
Block a user