patch 7.4.2015
Problem: When a file gets a name when writing it 'acd' is not effective.
(Dan Church)
Solution: Invoke DO_AUTOCHDIR after writing the file. (Allen Haim, closes
#777, closes #803) Add test_autochdir() to enable 'acd' before
"starting" is reset.
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 5900c86..d93a7ec 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3059,6 +3059,7 @@
char_u *browse_file = NULL;
#endif
buf_T *alt_buf = NULL;
+ int name_was_missing;
if (not_writing()) /* check 'write' option */
return FAIL;
@@ -3226,6 +3227,8 @@
#endif
}
+ name_was_missing = curbuf->b_ffname == NULL;
+
retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
eap, eap->append, eap->forceit, TRUE, FALSE);
@@ -3239,7 +3242,12 @@
redraw_tabline = TRUE;
#endif
}
- /* Change directories when the 'acd' option is set. */
+ }
+
+ /* Change directories when the 'acd' option is set and the file name
+ * got changed or set. */
+ if (eap->cmdidx == CMD_saveas || name_was_missing)
+ {
DO_AUTOCHDIR
}
}