mirror of
https://github.com/neovim/neovim.git
synced 2026-04-18 13:30:42 +00:00
fix(vim.fs): abspath(".") returns "/…/." (#36584)
fix(vim.fs): abspath(".") returns "/…/." #36583
(cherry picked from commit 1f9d9cb2e5)
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d974c684da
commit
6a507bad18
@@ -437,7 +437,7 @@ function M.root(source, marker)
|
||||
for _, mark in ipairs(markers) do
|
||||
local paths = M.find(mark, {
|
||||
upward = true,
|
||||
path = vim.fn.fnamemodify(path, ':p:h'),
|
||||
path = M.abspath(path),
|
||||
})
|
||||
|
||||
if #paths ~= 0 then
|
||||
@@ -747,6 +747,8 @@ end
|
||||
--- @param path string Path
|
||||
--- @return string Absolute path
|
||||
function M.abspath(path)
|
||||
-- TODO(justinmk): mark f_fnamemodify as API_FAST and use it, ":p:h" should be safe...
|
||||
|
||||
vim.validate('path', path, 'string')
|
||||
|
||||
-- Expand ~ to user's home directory
|
||||
@@ -773,7 +775,10 @@ function M.abspath(path)
|
||||
-- Convert cwd path separator to `/`
|
||||
cwd = cwd:gsub(os_sep, '/')
|
||||
|
||||
-- Prefix is not needed for expanding relative paths, as `cwd` already contains it.
|
||||
if path == '.' then
|
||||
return cwd
|
||||
end
|
||||
-- Prefix is not needed for expanding relative paths, `cwd` already contains it.
|
||||
return M.joinpath(cwd, path)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user