mirror of
https://github.com/neovim/neovim.git
synced 2026-08-25 16:41:52 +00:00
feat(dir): set buffer-local CWD #41174
This commit is contained in:
@@ -45,7 +45,7 @@ end
|
||||
local function assert_directory(path)
|
||||
local ffname = path:sub(-1) == '/' and path or path .. '/'
|
||||
eq(ffname, api.nvim_buf_get_name(0))
|
||||
eq(path, vim.fs.normalize(fn.bufname('%')))
|
||||
eq(path, vim.fs.normalize(fn.fnamemodify(fn.bufname('%'), ':p')))
|
||||
eq('directory', bufopt('filetype'))
|
||||
eq(true, bufopt('buflisted'))
|
||||
end
|
||||
@@ -576,19 +576,24 @@ describe('nvim.dir', function()
|
||||
it('navigates entries and refreshes the listing', function()
|
||||
make_fixture()
|
||||
n.clear({ args = { '--clean' } })
|
||||
local cwd = fn.getcwd()
|
||||
|
||||
edit(root)
|
||||
assert_directory(root)
|
||||
eq(vim.uv.fs_realpath(root), vim.uv.fs_realpath(fn.getcwd()))
|
||||
eq('alpha.txt', fn.findfile('alpha.txt'))
|
||||
|
||||
api.nvim_win_set_cursor(0, { line_of('alpha.txt'), 0 })
|
||||
feed('<CR>')
|
||||
poke_eventloop()
|
||||
eq(file, api.nvim_buf_get_name(0))
|
||||
eq({ 'alpha' }, lines())
|
||||
eq(cwd, fn.getcwd())
|
||||
|
||||
edit(subdir)
|
||||
assert_directory(subdir)
|
||||
eq({ '' }, lines())
|
||||
eq(vim.uv.fs_realpath(subdir), vim.uv.fs_realpath(fn.getcwd()))
|
||||
|
||||
feed('-')
|
||||
poke_eventloop()
|
||||
|
||||
Reference in New Issue
Block a user