mirror of
https://github.com/neovim/neovim.git
synced 2025-11-03 09:14:24 +00:00
fix(api): ignore 'autochdir' when setting buf in other win (#28371)
Problem: Wrong working directory when setting buffer in another window with
'autochdir' enabled.
Solution: Temporarily disable 'autochdir'.
This commit is contained in:
@@ -1748,6 +1748,31 @@ describe('API/win', function()
|
||||
pcall_err(api.nvim_open_win, 0, true, { split = 'below', win = 0 })
|
||||
)
|
||||
end)
|
||||
|
||||
it('do not change dir when enter is false', function()
|
||||
local expected = fn.getcwd() .. '/foo'
|
||||
t.mkdir('foo')
|
||||
exec_lua [[
|
||||
vim.opt.autochdir = true
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_name(buf, 'Foo')
|
||||
vim.api.nvim_create_autocmd('CmdlineEnter', {
|
||||
callback = function()
|
||||
local winid = vim.api.nvim_open_win(buf, false, {
|
||||
relative = 'editor',
|
||||
height = 1,
|
||||
width = 1,
|
||||
row = 1,
|
||||
col = 1,
|
||||
})
|
||||
vim.api.nvim_win_close(winid, true)
|
||||
end,
|
||||
})
|
||||
]]
|
||||
t.feed(':edit foo/bar.txt<CR>')
|
||||
eq(t.is_os('win') and expected:gsub('/', '\\') or expected, fn.getcwd())
|
||||
t.rmdir('foo')
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('set_config', function()
|
||||
|
||||
Reference in New Issue
Block a user