diff options
Diffstat (limited to 'test/functional/autocmd/dirchanged_spec.lua')
-rw-r--r-- | test/functional/autocmd/dirchanged_spec.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/functional/autocmd/dirchanged_spec.lua b/test/functional/autocmd/dirchanged_spec.lua index 2e1aff3914..ce3b2e8d3e 100644 --- a/test/functional/autocmd/dirchanged_spec.lua +++ b/test/functional/autocmd/dirchanged_spec.lua @@ -6,6 +6,7 @@ local command = h.command local eq = h.eq local eval = h.eval local request = h.request +local iswin = h.iswin describe('autocmd DirChanged', function() local curdir = string.gsub(lfs.currentdir(), '\\', '/') @@ -14,6 +15,11 @@ describe('autocmd DirChanged', function() curdir .. '/Xtest-functional-autocmd-dirchanged.dir2', curdir .. '/Xtest-functional-autocmd-dirchanged.dir3', } + local win_dirs = { + curdir .. '\\XTEST-FUNCTIONAL-AUTOCMD-DIRCHANGED.DIR1', + curdir .. '\\XTEST-FUNCTIONAL-AUTOCMD-DIRCHANGED.DIR2', + curdir .. '\\XTEST-FUNCTIONAL-AUTOCMD-DIRCHANGED.DIR3', + } setup(function() for _, dir in pairs(dirs) do h.mkdir(dir) end end) teardown(function() for _, dir in pairs(dirs) do h.rmdir(dir) end end) @@ -122,6 +128,12 @@ describe('autocmd DirChanged', function() eq({}, eval('g:ev')) eq(1, eval('g:cdcount')) + if iswin() then + command('lcd '..win_dirs[1]) + eq({}, eval('g:ev')) + eq(1, eval('g:cdcount')) + end + command('tcd '..dirs[2]) eq({cwd=dirs[2], scope='tab', changed_window=false}, eval('g:ev')) eq(2, eval('g:cdcount')) @@ -130,6 +142,12 @@ describe('autocmd DirChanged', function() eq({}, eval('g:ev')) eq(2, eval('g:cdcount')) + if iswin() then + command('tcd '..win_dirs[2]) + eq({}, eval('g:ev')) + eq(2, eval('g:cdcount')) + end + command('cd '..dirs[3]) eq({cwd=dirs[3], scope='global', changed_window=false}, eval('g:ev')) eq(3, eval('g:cdcount')) @@ -138,6 +156,12 @@ describe('autocmd DirChanged', function() eq({}, eval('g:ev')) eq(3, eval('g:cdcount')) + if iswin() then + command('cd '..win_dirs[3]) + eq({}, eval('g:ev')) + eq(3, eval('g:cdcount')) + end + command('set autochdir') command('split '..dirs[1]..'/foo') @@ -147,6 +171,12 @@ describe('autocmd DirChanged', function() command('split '..dirs[1]..'/bar') eq({}, eval('g:ev')) eq(4, eval('g:cdcount')) + + if iswin() then + command('split '..win_dirs[1]..'/baz') + eq({}, eval('g:ev')) + eq(4, eval('g:cdcount')) + end end) it("is triggered by switching to win/tab with different CWD #6054", function() @@ -174,6 +204,31 @@ describe('autocmd DirChanged', function() eq(9, eval('g:cdcount')) command('tabnext') -- tab 2 (has the *same* CWD) eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + + if iswin() then + command('tabnew') -- tab 3 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tcd '..win_dirs[3]) + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabnext') -- tab 1 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabprevious') -- tab 3 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabprevious') -- tab 2 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabprevious') -- tab 1 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('lcd '..win_dirs[3]) -- window 3 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabnext') -- tab 2 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabnext') -- tab 3 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabnext') -- tab 1 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + command('tabprevious') -- tab 3 + eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event + end end) it('is triggered by nvim_set_current_dir()', function() |