Mercurial > vim
comparison src/ex_cmds.c @ 9469:38e2fc4ee4ef v7.4.2015
commit https://github.com/vim/vim/commit/5c71994f4ee5f87d4cce990dbc9684c70b1e108b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 9 23:40:45 2016 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 09 Jul 2016 23:45:05 +0200 |
parents | 1003973c99df |
children | 7520696c14b0 |
comparison
equal
deleted
inserted
replaced
9468:7070daf57525 | 9469:38e2fc4ee4ef |
---|---|
3057 char_u *free_fname = NULL; | 3057 char_u *free_fname = NULL; |
3058 #ifdef FEAT_BROWSE | 3058 #ifdef FEAT_BROWSE |
3059 char_u *browse_file = NULL; | 3059 char_u *browse_file = NULL; |
3060 #endif | 3060 #endif |
3061 buf_T *alt_buf = NULL; | 3061 buf_T *alt_buf = NULL; |
3062 int name_was_missing; | |
3062 | 3063 |
3063 if (not_writing()) /* check 'write' option */ | 3064 if (not_writing()) /* check 'write' option */ |
3064 return FAIL; | 3065 return FAIL; |
3065 | 3066 |
3066 ffname = eap->arg; | 3067 ffname = eap->arg; |
3224 * 'autochdir' is set. */ | 3225 * 'autochdir' is set. */ |
3225 fname = curbuf->b_sfname; | 3226 fname = curbuf->b_sfname; |
3226 #endif | 3227 #endif |
3227 } | 3228 } |
3228 | 3229 |
3230 name_was_missing = curbuf->b_ffname == NULL; | |
3231 | |
3229 retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2, | 3232 retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2, |
3230 eap, eap->append, eap->forceit, TRUE, FALSE); | 3233 eap, eap->append, eap->forceit, TRUE, FALSE); |
3231 | 3234 |
3232 /* After ":saveas fname" reset 'readonly'. */ | 3235 /* After ":saveas fname" reset 'readonly'. */ |
3233 if (eap->cmdidx == CMD_saveas) | 3236 if (eap->cmdidx == CMD_saveas) |
3237 curbuf->b_p_ro = FALSE; | 3240 curbuf->b_p_ro = FALSE; |
3238 #ifdef FEAT_WINDOWS | 3241 #ifdef FEAT_WINDOWS |
3239 redraw_tabline = TRUE; | 3242 redraw_tabline = TRUE; |
3240 #endif | 3243 #endif |
3241 } | 3244 } |
3242 /* Change directories when the 'acd' option is set. */ | 3245 } |
3246 | |
3247 /* Change directories when the 'acd' option is set and the file name | |
3248 * got changed or set. */ | |
3249 if (eap->cmdidx == CMD_saveas || name_was_missing) | |
3250 { | |
3243 DO_AUTOCHDIR | 3251 DO_AUTOCHDIR |
3244 } | 3252 } |
3245 } | 3253 } |
3246 | 3254 |
3247 theend: | 3255 theend: |