aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-02-17 06:07:19 +0800
committerGitHub <noreply@github.com>2022-02-17 06:07:19 +0800
commit4646ea1079de484c4217006f94c565ea508f2f40 (patch)
treee084eb9b32e6b986269194a6e4d450eccc16738b /src/nvim/ex_docmd.c
parent8ab5ec4aaaeed27b1d8086d395171a52568378c2 (diff)
parent059d36e326e31fc9bc6055d7c999f86d94fa9bd5 (diff)
downloadrneovim-4646ea1079de484c4217006f94c565ea508f2f40.tar.gz
rneovim-4646ea1079de484c4217006f94c565ea508f2f40.tar.bz2
rneovim-4646ea1079de484c4217006f94c565ea508f2f40.zip
Merge pull request #17363 from zeertzjq/dirchangedpre
feat(events): add DirChangedPre
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 87f8865133..9991584862 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -7797,7 +7797,7 @@ static char_u *get_prevdir(CdScope scope)
/// 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, bool trigger_dirchanged)
+static void post_chdir(CdScope scope, bool trigger_dirchanged)
{
// Always overwrite the window-local CWD.
XFREE_CLEAR(curwin->w_localdir);
@@ -7838,7 +7838,7 @@ void post_chdir(CdScope scope, bool trigger_dirchanged)
shorten_fnames(true);
if (trigger_dirchanged) {
- do_autocmd_dirchanged(cwd, scope, kCdCauseManual);
+ do_autocmd_dirchanged(cwd, scope, kCdCauseManual, false);
}
}
@@ -7882,10 +7882,13 @@ bool changedir_func(char_u *new_dir, CdScope scope)
}
bool dir_differs = pdir == NULL || pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
- if (dir_differs && vim_chdir(new_dir) != 0) {
- emsg(_(e_failed));
- xfree(pdir);
- return false;
+ if (dir_differs) {
+ do_autocmd_dirchanged((char *)new_dir, scope, kCdCauseManual, true);
+ if (vim_chdir(new_dir) != 0) {
+ emsg(_(e_failed));
+ xfree(pdir);
+ return false;
+ }
}
char_u **pp;