mirror of
https://github.com/neovim/neovim.git
synced 2026-07-10 19:39:38 +00:00
fix(dir): preserve alternate buffer #40659
This commit is contained in:
@@ -85,7 +85,14 @@ local function render(buf, dir)
|
||||
then
|
||||
return false
|
||||
end
|
||||
api.nvim_buf_set_name(buf, dir)
|
||||
api.nvim_buf_call(buf, function()
|
||||
api.nvim_cmd({
|
||||
cmd = 'file',
|
||||
args = { dir },
|
||||
mods = { keepalt = true },
|
||||
magic = { file = false, bar = false },
|
||||
}, {})
|
||||
end)
|
||||
if not api.nvim_buf_is_valid(buf) then
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -164,6 +164,19 @@ describe('nvim.dir', function()
|
||||
eq(false, exec_lua([[return package.loaded['nvim.dir'] ~= nil]]))
|
||||
end)
|
||||
|
||||
it('preserves alternate buffer when opening a parent directory', function()
|
||||
make_fixture()
|
||||
n.clear({ args_rm = { '-u', '--cmd' } })
|
||||
|
||||
edit(file)
|
||||
feed('-')
|
||||
poke_eventloop()
|
||||
|
||||
assert_directory(root)
|
||||
-- Keep the alternate buffer on the file we navigated up from.
|
||||
eq(file, api.nvim_buf_get_name(fn.bufnr('#')))
|
||||
end)
|
||||
|
||||
it('uses an absolute buffer name for a relative startup directory argument', function()
|
||||
make_fixture()
|
||||
local cwd = assert(vim.uv.cwd())
|
||||
|
||||
Reference in New Issue
Block a user