forked from aniani/vim
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Problem: DirChanged is also triggered when the directory didn't change. (Daniel Hahler) Solution: Compare the current with the new directory. (closes #3697)
This commit is contained in:
@@ -9126,8 +9126,9 @@ post_chdir(int local)
|
||||
void
|
||||
ex_cd(exarg_T *eap)
|
||||
{
|
||||
char_u *new_dir;
|
||||
char_u *tofree;
|
||||
char_u *new_dir;
|
||||
char_u *tofree;
|
||||
int dir_differs;
|
||||
|
||||
new_dir = eap->arg;
|
||||
#if !defined(UNIX) && !defined(VMS)
|
||||
@@ -9183,7 +9184,9 @@ ex_cd(exarg_T *eap)
|
||||
new_dir = NameBuff;
|
||||
}
|
||||
#endif
|
||||
if (new_dir == NULL || vim_chdir(new_dir))
|
||||
dir_differs = new_dir == NULL || prev_dir == NULL
|
||||
|| STRCMP(prev_dir, new_dir) != 0;
|
||||
if (new_dir == NULL || (dir_differs && vim_chdir(new_dir)))
|
||||
EMSG(_(e_failed));
|
||||
else
|
||||
{
|
||||
@@ -9195,9 +9198,11 @@ ex_cd(exarg_T *eap)
|
||||
/* Echo the new current directory if the command was typed. */
|
||||
if (KeyTyped || p_verbose >= 5)
|
||||
ex_pwd(eap);
|
||||
apply_autocmds(EVENT_DIRCHANGED,
|
||||
is_local_chdir ? (char_u *)"window" : (char_u *)"global",
|
||||
new_dir, FALSE, curbuf);
|
||||
|
||||
if (dir_differs)
|
||||
apply_autocmds(EVENT_DIRCHANGED,
|
||||
is_local_chdir ? (char_u *)"window" : (char_u *)"global",
|
||||
new_dir, FALSE, curbuf);
|
||||
}
|
||||
vim_free(tofree);
|
||||
}
|
||||
|
Reference in New Issue
Block a user