mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 11:26:37 +00:00
options: properly reset directories on 'autochdir' (#9894)
Fixes https://github.com/neovim/neovim/issues/9892
This commit is contained in:
@@ -690,7 +690,7 @@ void nvim_set_current_dir(String dir, Error *err)
|
||||
return;
|
||||
}
|
||||
|
||||
post_chdir(kCdScopeGlobal);
|
||||
post_chdir(kCdScopeGlobal, true);
|
||||
try_end(err);
|
||||
}
|
||||
|
||||
|
@@ -1620,6 +1620,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);
|
||||
}
|
||||
}
|
||||
|
@@ -7241,7 +7241,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);
|
||||
@@ -7281,7 +7281,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`.
|
||||
@@ -7343,7 +7346,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);
|
||||
|
Reference in New Issue
Block a user