aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-02-11 12:44:47 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-02-11 12:55:58 +0800
commit059d36e326e31fc9bc6055d7c999f86d94fa9bd5 (patch)
tree53577f4456663a3315e0d485914c3a4d6c4e2f42 /src/nvim/ex_docmd.c
parent851252f79ddaaca5456b287342cd36130c76ff38 (diff)
downloadrneovim-059d36e326e31fc9bc6055d7c999f86d94fa9bd5.tar.gz
rneovim-059d36e326e31fc9bc6055d7c999f86d94fa9bd5.tar.bz2
rneovim-059d36e326e31fc9bc6055d7c999f86d94fa9bd5.zip
feat(events): add DirChangedPre
In Nvim, like DirChanged, this also triggers when switching windows. This marks Vim patch 8.2.4335 as ported. vim-patch:8.2.4335: no autocommand event triggered before changing directory Problem: No autocommand event triggered before changing directory. (Ronnie Magatti) Solution: Add DirChangedPre. (closes vim/vim#9721) https://github.com/vim/vim/commit/28e8f73ae2d90009fd62cd60f97c2643ba44de68
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 d884838136..8b6d7b91a8 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -7784,7 +7784,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);
@@ -7825,7 +7825,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);
}
}
@@ -7869,10 +7869,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;