mirror of
https://github.com/neovim/neovim.git
synced 2025-12-12 01:22:41 +00:00
feat(ui): add chdir UI event (#27093)
When an embedded Nvim instance changes its current directory a "chdir" UI event is emitted. Attached UIs can use this information however they wish. In the TUI it is used to synchronize the cwd of the TUI process with the cwd of the embedded Nvim process.
This commit is contained in:
@@ -171,6 +171,56 @@ describe('--embed UI', function()
|
||||
}
|
||||
eq({ [16711935] = true }, seen) -- we only saw the last one, despite 16777215 was set internally earlier
|
||||
end)
|
||||
|
||||
it('updates cwd of attached UI #21771', function()
|
||||
clear { args_rm = { '--headless' } }
|
||||
|
||||
local screen = Screen.new(40, 8)
|
||||
screen:attach()
|
||||
|
||||
screen:expect {
|
||||
condition = function()
|
||||
eq(helpers.paths.test_source_path, screen.pwd)
|
||||
end,
|
||||
}
|
||||
|
||||
-- Change global cwd
|
||||
helpers.command(string.format('cd %s/src/nvim', helpers.paths.test_source_path))
|
||||
|
||||
screen:expect {
|
||||
condition = function()
|
||||
eq(string.format('%s/src/nvim', helpers.paths.test_source_path), screen.pwd)
|
||||
end,
|
||||
}
|
||||
|
||||
-- Split the window and change the cwd in the split
|
||||
helpers.command('new')
|
||||
helpers.command(string.format('lcd %s/test', helpers.paths.test_source_path))
|
||||
|
||||
screen:expect {
|
||||
condition = function()
|
||||
eq(string.format('%s/test', helpers.paths.test_source_path), screen.pwd)
|
||||
end,
|
||||
}
|
||||
|
||||
-- Move to the original window
|
||||
helpers.command('wincmd p')
|
||||
|
||||
screen:expect {
|
||||
condition = function()
|
||||
eq(string.format('%s/src/nvim', helpers.paths.test_source_path), screen.pwd)
|
||||
end,
|
||||
}
|
||||
|
||||
-- Change global cwd again
|
||||
helpers.command(string.format('cd %s', helpers.paths.test_source_path))
|
||||
|
||||
screen:expect {
|
||||
condition = function()
|
||||
eq(helpers.paths.test_source_path, screen.pwd)
|
||||
end,
|
||||
}
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('--embed --listen UI', function()
|
||||
|
||||
Reference in New Issue
Block a user