From 4ceb92cd76d0234dd7b3ad775d94de46be108b21 Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Sat, 12 Sep 2026 09:01:41 +1000 Subject: feat(dir): open entries in splits with a, o mappings #41834 --- test/functional/plugin/dir_spec.lua | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'test/functional/plugin') diff --git a/test/functional/plugin/dir_spec.lua b/test/functional/plugin/dir_spec.lua index b7318473c3..67cbb5ddd3 100644 --- a/test/functional/plugin/dir_spec.lua +++ b/test/functional/plugin/dir_spec.lua @@ -572,7 +572,7 @@ describe('nvim.dir', function() eq({ 'unsaved' }, api.nvim_buf_get_lines(old_buf, 0, -1, false)) end) - it('does not shadow startup plugin `-` mappings in directory buffers', function() + it('does not shadow startup plugin mappings in directory buffers', function() make_fixture() write_config_plugin( 'plugin/dirvish.lua', @@ -581,6 +581,8 @@ describe('nvim.dir', function() vim.keymap.set('n', '-', function() vim.g.dirvish_up = vim.g.dirvish_up + 1 end) + vim.keymap.set('n', 'a', '') + vim.keymap.set('n', 's', '(nvim-dir-split)') ]] ) @@ -591,12 +593,17 @@ describe('nvim.dir', function() edit(root) assert_directory(root) eq(0, fn.maparg('-', 'n', false, true).buffer) + eq('', fn.maparg('a', 'n')) + eq('', fn.maparg('o', 'n')) - feed('-') + feed('-as') poke_eventloop() eq(1, exec_lua('return vim.g.dirvish_up')) assert_directory(root) + eq(2, #api.nvim_list_wins()) + feed('p') + assert_directory(subdir) end) it('preserves alternate buffer when opening a parent directory', function() @@ -669,6 +676,22 @@ describe('nvim.dir', function() eq(vim.uv.fs_realpath(root), vim.uv.fs_realpath(fn.getcwd())) eq('alpha.txt', fn.findfile('alpha.txt')) + local win = api.nvim_get_current_win() + for key, entry in pairs({ a = 'alpha.txt', o = 'subdir/' }) do + local cursor = { line_of(entry), 0 } + api.nvim_win_set_cursor(0, cursor) + feed(key) + poke_eventloop() + eq(win, api.nvim_get_current_win()) + assert_directory(root) + eq(cursor, api.nvim_win_get_cursor(0)) + eq(2, #api.nvim_list_wins()) + eq(key == 'a' and 'row' or 'col', fn.winlayout()[1]) + feed('p') + eq(root .. '/' .. entry, api.nvim_buf_get_name(0)) + command('close') + end + api.nvim_win_set_cursor(0, { line_of('alpha.txt'), 0 }) feed('') poke_eventloop() @@ -680,6 +703,9 @@ describe('nvim.dir', function() assert_directory(subdir) eq({ '' }, lines()) eq(vim.uv.fs_realpath(subdir), vim.uv.fs_realpath(fn.getcwd())) + feed('ao') + poke_eventloop() + eq(1, #api.nvim_list_wins()) feed('-') poke_eventloop() @@ -824,7 +850,7 @@ describe('nvim.dir', function() line_of(raw_name) end api.nvim_win_set_cursor(0, { line_of('line\0break.txt'), 0 }) - feed('') + feed('ap') poke_eventloop() eq(root .. '/' .. name, api.nvim_buf_get_name(0)) -- cgit