diff options
| author | Barrett Ruth <62671086+barrettruth@users.noreply.github.com> | 2026-07-24 03:45:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-24 06:45:13 -0400 |
| commit | ce9cc43f23d749261d63c06e1e330cf49b01f533 (patch) | |
| tree | 049498296c9d22ef54b601e2aa98e20f3721ce48 /test/functional/plugin/dir_spec.lua | |
| parent | 66441e549d5c560f8b1d6d6b6e71244ce3569604 (diff) | |
| download | rneovim-ce9cc43f23d749261d63c06e1e330cf49b01f533.tar.gz rneovim-ce9cc43f23d749261d63c06e1e330cf49b01f533.tar.bz2 rneovim-ce9cc43f23d749261d63c06e1e330cf49b01f533.zip | |
fix(dir): open CWD from unnamed buffer with `-` mapping #40926
Diffstat (limited to 'test/functional/plugin/dir_spec.lua')
| -rw-r--r-- | test/functional/plugin/dir_spec.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/functional/plugin/dir_spec.lua b/test/functional/plugin/dir_spec.lua index 339ebefda0..0a598e4204 100644 --- a/test/functional/plugin/dir_spec.lua +++ b/test/functional/plugin/dir_spec.lua @@ -363,6 +363,43 @@ describe('nvim.dir', function() eq('alpha.txt', api.nvim_get_current_line()) end) + it('maps - to open the current directory from an unnamed buffer', function() + make_fixture() + n.clear({ args_rm = { '-u', '--cmd' } }) + local cwd = fn.getcwd() + cd(root) + finally(function() + cd(cwd) + end) + + eq('', api.nvim_buf_get_name(0)) + feed('-') + poke_eventloop() + + assert_directory(root) + end) + + it('preserves a modified unnamed buffer when opening the current directory', function() + make_fixture() + n.clear({ args_rm = { '-u', '--cmd' } }) + local cwd = fn.getcwd() + cd(root) + finally(function() + cd(cwd) + end) + local old_buf = api.nvim_get_current_buf() + api.nvim_buf_set_lines(old_buf, 0, -1, false, { 'unsaved' }) + + feed('-') + poke_eventloop() + + assert_directory(root) + eq(old_buf, fn.bufnr('#')) + eq(true, api.nvim_buf_is_valid(old_buf)) + eq(true, api.nvim_get_option_value('modified', { buf = old_buf })) + eq({ 'unsaved' }, api.nvim_buf_get_lines(old_buf, 0, -1, false)) + end) + it('does not shadow startup plugin `-` mappings in directory buffers', function() make_fixture() write_config_plugin( |