mirror of
https://github.com/neovim/neovim.git
synced 2026-04-19 22:10:45 +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
@@ -412,23 +412,31 @@ describe('vim.fs', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('uses cwd for unnamed buffers', function()
|
||||
it('returns CWD (absolute path) for unnamed buffers', function()
|
||||
assert(n.fn.isabsolutepath(test_source_path) == 1)
|
||||
command('new')
|
||||
eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
|
||||
eq(
|
||||
t.fix_slashes(test_source_path),
|
||||
t.fix_slashes(exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
|
||||
)
|
||||
end)
|
||||
|
||||
it("uses cwd for buffers with non-empty 'buftype'", function()
|
||||
it("returns CWD (absolute path) for buffers with non-empty 'buftype'", function()
|
||||
assert(n.fn.isabsolutepath(test_source_path) == 1)
|
||||
command('new')
|
||||
command('set buftype=nofile')
|
||||
command('file lua://')
|
||||
eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
|
||||
eq(
|
||||
t.fix_slashes(test_source_path),
|
||||
t.fix_slashes(exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]]))
|
||||
)
|
||||
end)
|
||||
|
||||
it('returns an absolute path for an invalid filename', function()
|
||||
it('returns CWD (absolute path) if no match is found', function()
|
||||
assert(n.fn.isabsolutepath(test_source_path) == 1)
|
||||
eq(
|
||||
t.fix_slashes(test_source_path),
|
||||
t.fix_slashes(exec_lua([[return vim.fs.root('file://asd', 'CMakePresets.json')]]))
|
||||
t.fix_slashes(exec_lua([[return vim.fs.root('file://bogus', 'CMakePresets.json')]]))
|
||||
)
|
||||
end)
|
||||
end)
|
||||
@@ -612,7 +620,9 @@ describe('vim.fs', function()
|
||||
local cwd = assert(t.fix_slashes(assert(vim.uv.cwd())))
|
||||
local home = t.fix_slashes(assert(vim.uv.os_homedir()))
|
||||
|
||||
it('works', function()
|
||||
it('expands relative paths', function()
|
||||
assert(n.fn.isabsolutepath(cwd) == 1)
|
||||
eq(cwd, vim.fs.abspath('.'))
|
||||
eq(cwd .. '/foo', vim.fs.abspath('foo'))
|
||||
eq(cwd .. '/././foo', vim.fs.abspath('././foo'))
|
||||
eq(cwd .. '/.././../foo', vim.fs.abspath('.././../foo'))
|
||||
|
||||
Reference in New Issue
Block a user