feat(vim.fs): root() can specify "equal priority" #34276

This commit is contained in:
Siddhant Agarwal
2025-06-09 22:01:37 +05:30
committed by GitHub
parent 2d980e37c8
commit 2f0fbdaa48
5 changed files with 80 additions and 21 deletions

View File

@ -366,6 +366,36 @@ describe('vim.fs', function()
)
end)
it('nested markers have equal priority', function()
local bufnr = api.nvim_get_current_buf()
eq(
vim.fs.joinpath(test_source_path, 'test/functional'),
exec_lua(
[[return vim.fs.root(..., { 'example_spec.lua', {'CMakeLists.txt', 'CMakePresets.json'}, '.luarc.json'})]],
bufnr
)
)
eq(
vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
exec_lua(
[[return vim.fs.root(..., { {'CMakeLists.txt', 'CMakePresets.json'}, 'example_spec.lua', '.luarc.json'})]],
bufnr
)
)
eq(
vim.fs.joinpath(test_source_path, 'test/functional/fixtures'),
exec_lua(
[[return vim.fs.root(..., {
function(name, _)
return name:match('%.txt$')
end,
'example_spec.lua',
'.luarc.json' })]],
bufnr
)
)
end)
it('works with a function', function()
---@type string
local result = exec_lua(function()