fix(dir): :browse edit opens dir browser #40930

Problem: `:browse edit` (and variants) without an argument fails instead
of opening a browser.

Solution: Dispatch to dir.lua using the cwd as the implied directory.
Replace the inherited GUI-only documentation with the supported
behavior. Support vsplit, split, tabedit variants.
This commit is contained in:
Barrett Ruth
2026-07-25 03:56:52 -07:00
committed by GitHub
parent fb6fb33d39
commit 4975a186f2
4 changed files with 65 additions and 99 deletions

View File

@@ -683,19 +683,29 @@ describe('nvim.dir', function()
eq('netrw', api.nvim_get_option_value('filetype', { buf = 0 }))
end)
it('supports the FileExplorer browse contract', function()
if t.is_zig_build() then
return pending('broken with build.zig: TMPDIR relative cwd')
end
make_fixture()
n.clear({ args_rm = { '-u' } })
local cwd = fn.getcwd()
for _, case in ipairs({
{ command = 'edit', windows = 1, tabs = 1 },
{ command = 'split', windows = 2, tabs = 1 },
{ command = 'vsplit', windows = 2, tabs = 1 },
{ command = 'tabedit', windows = 1, tabs = 2 },
{ command = 'tabnew', windows = 1, tabs = 2 },
}) do
it(('":browse %s"'):format(case.command), function()
if t.is_zig_build() then
return pending('broken with build.zig: TMPDIR relative cwd')
end
make_fixture()
n.clear({ args_rm = { '-u' } })
local cwd = fn.getcwd()
cd(root)
command('browse edit .')
cd(cwd)
cd(root)
command('browse ' .. case.command)
cd(cwd)
assert_directory(root)
line_of('alpha.txt')
end)
eq(case.windows, #api.nvim_tabpage_list_wins(0))
eq(case.tabs, #api.nvim_list_tabpages())
assert_directory(root)
line_of('alpha.txt')
end)
end
end)