diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2019-04-13 12:50:36 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-15 21:04:16 +0200 |
commit | f891131c6bb2ab399130e28c9e483e071dafcbcb (patch) | |
tree | c98d3ba4ccae34914701f5e93f9370ee632c0ab0 /src | |
parent | 9a5488c2a67e0066d4f2f8aeaf8058deaa58ce7a (diff) | |
download | rneovim-f891131c6bb2ab399130e28c9e483e071dafcbcb.tar.gz rneovim-f891131c6bb2ab399130e28c9e483e071dafcbcb.tar.bz2 rneovim-f891131c6bb2ab399130e28c9e483e071dafcbcb.zip |
options: properly reset directories on 'autochdir' (#9894)
Fixes https://github.com/neovim/neovim/issues/9892
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/vim.c | 2 | ||||
-rw-r--r-- | src/nvim/buffer.c | 1 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 9 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index ecfff1ea8f..ac1b686595 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -594,7 +594,7 @@ void nvim_set_current_dir(String dir, Error *err) return; } - post_chdir(kCdScopeGlobal); + post_chdir(kCdScopeGlobal, true); try_end(err); } diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 8b107041b1..f74c66f106 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1559,6 +1559,7 @@ void do_autochdir(void) if (starting == 0 && curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK) { + post_chdir(kCdScopeGlobal, false); shorten_fnames(true); } } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 4ef332186e..319bceccec 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7218,7 +7218,7 @@ void free_cd_dir(void) /// Deal with the side effects of changing the current directory. /// /// @param scope Scope of the function call (global, tab or window). -void post_chdir(CdScope scope) +void post_chdir(CdScope scope, bool trigger_dirchanged) { // Always overwrite the window-local CWD. xfree(curwin->w_localdir); @@ -7258,7 +7258,10 @@ void post_chdir(CdScope scope) } shorten_fnames(true); - do_autocmd_dirchanged(cwd, scope); + + if (trigger_dirchanged) { + do_autocmd_dirchanged(cwd, scope); + } } /// `:cd`, `:tcd`, `:lcd`, `:chdir`, `:tchdir` and `:lchdir`. @@ -7320,7 +7323,7 @@ void ex_cd(exarg_T *eap) if (vim_chdir(new_dir, scope)) { EMSG(_(e_failed)); } else { - post_chdir(scope); + post_chdir(scope, true); // Echo the new current directory if the command was typed. if (KeyTyped || p_verbose >= 5) { ex_pwd(eap); |