From cca407b43e62d5e1abdfc59ae47b0e24eacc5807 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Fri, 16 Mar 2018 07:29:20 +0100 Subject: [PATCH] DirChanged: support (#8140) --- src/nvim/file_search.c | 2 +- test/functional/autocmd/dirchanged_spec.lua | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index c6f2166dab..3272ce81bc 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1560,7 +1560,7 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope) tv_dict_set_keys_readonly(dict); apply_autocmds(EVENT_DIRCHANGED, (char_u *)buf, (char_u *)new_dir, false, - NULL); + curbuf); tv_dict_clear(dict); diff --git a/test/functional/autocmd/dirchanged_spec.lua b/test/functional/autocmd/dirchanged_spec.lua index 63cf0bc410..7979e91a4c 100644 --- a/test/functional/autocmd/dirchanged_spec.lua +++ b/test/functional/autocmd/dirchanged_spec.lua @@ -154,4 +154,11 @@ describe('autocmd DirChanged', function() eq('Failed to change directory', string.match(err, ': (.*)')) eq({cwd=dirs[2], scope='global'}, eval('g:ev')) end) + + it('works when local to buffer', function() + command('let g:triggered = 0') + command('autocmd DirChanged let g:triggered = 1') + command('cd '..dirs[1]) + eq(1, eval('g:triggered')) + end) end)