mirror of
https://github.com/neovim/neovim.git
synced 2026-07-14 21:30:34 +00:00
fix(fs): make vim.fs.root work for relative paths and unnamed buffers (#28973)
If a buffer does not have a backing file then fall back to the current
working directory.
(cherry picked from commit 206f8f24a2)
This commit is contained in:
committed by
GitHub
parent
28f03205be
commit
bf16fe3f01
@@ -310,6 +310,25 @@ describe('vim.fs', function()
|
||||
it('works with a filename argument', function()
|
||||
eq(test_source_path, exec_lua([[return vim.fs.root(..., '.git')]], nvim_prog))
|
||||
end)
|
||||
|
||||
it('works with a relative path', function()
|
||||
eq(
|
||||
test_source_path,
|
||||
exec_lua([[return vim.fs.root(..., '.git')]], vim.fs.basename(nvim_prog))
|
||||
)
|
||||
end)
|
||||
|
||||
it('uses cwd for unnamed buffers', function()
|
||||
command('new')
|
||||
eq(test_source_path, exec_lua([[return vim.fs.root(0, '.git')]]))
|
||||
end)
|
||||
|
||||
it("uses cwd for buffers with non-empty 'buftype'", function()
|
||||
command('new')
|
||||
command('set buftype=nofile')
|
||||
command('file lua://')
|
||||
eq(test_source_path, exec_lua([[return vim.fs.root(0, '.git')]]))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('joinpath()', function()
|
||||
|
||||
Reference in New Issue
Block a user