aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 5d83e2218b..b81aab9ffe 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -7811,10 +7811,11 @@ void ex_cd(exarg_T *eap)
break;
}
- if (vim_chdir(new_dir)) {
+ bool dir_differs = prev_dir == NULL || STRCMP(prev_dir, new_dir) != 0;
+ if (dir_differs && vim_chdir(new_dir)) {
EMSG(_(e_failed));
} else {
- post_chdir(scope, true);
+ post_chdir(scope, dir_differs);
// Echo the new current directory if the command was typed.
if (KeyTyped || p_verbose >= 5) {
ex_pwd(eap);