mirror of
https://github.com/zoriya/vim.git
synced 2025-12-19 13:45:18 +00:00
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.
This commit is contained in:
@@ -2016,6 +2016,7 @@ test1 \
|
||||
test_arglist \
|
||||
test_assert \
|
||||
test_assign \
|
||||
test_autochdir \
|
||||
test_autocmd \
|
||||
test_backspace_opt \
|
||||
test_cdo \
|
||||
|
||||
@@ -1635,7 +1635,7 @@ enter_buffer(buf_T *buf)
|
||||
void
|
||||
do_autochdir(void)
|
||||
{
|
||||
if (starting == 0
|
||||
if ((starting == 0 || test_autochdir)
|
||||
&& curbuf->b_ffname != NULL
|
||||
&& vim_chdirfile(curbuf->b_ffname) == OK)
|
||||
shorten_fnames(TRUE);
|
||||
|
||||
13
src/eval.c
13
src/eval.c
@@ -812,6 +812,7 @@ static void f_taglist(typval_T *argvars, typval_T *rettv);
|
||||
static void f_tagfiles(typval_T *argvars, typval_T *rettv);
|
||||
static void f_tempname(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_alloc_fail(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_disable_char_avail(typval_T *argvars, typval_T *rettv);
|
||||
static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
@@ -8832,6 +8833,7 @@ static struct fst
|
||||
#endif
|
||||
{"tempname", 0, 0, f_tempname},
|
||||
{"test_alloc_fail", 3, 3, f_test_alloc_fail},
|
||||
{"test_autochdir", 0, 0, f_test_autochdir},
|
||||
{"test_disable_char_avail", 1, 1, f_test_disable_char_avail},
|
||||
{"test_garbagecollect_now", 0, 0, f_test_garbagecollect_now},
|
||||
#ifdef FEAT_JOB_CHANNEL
|
||||
@@ -21076,6 +21078,17 @@ f_test_alloc_fail(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "test_autochdir()"
|
||||
*/
|
||||
static void
|
||||
f_test_autochdir(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
{
|
||||
#if defined(FEAT_AUTOCHDIR)
|
||||
test_autochdir = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* "test_disable_char_avail({expr})" function
|
||||
*/
|
||||
|
||||
@@ -3059,6 +3059,7 @@ do_write(exarg_T *eap)
|
||||
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 @@ do_write(exarg_T *eap)
|
||||
#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 @@ do_write(exarg_T *eap)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,6 +635,9 @@ EXTERN int exiting INIT(= FALSE);
|
||||
EXTERN int really_exiting INIT(= FALSE);
|
||||
/* TRUE when we are sure to exit, e.g., after
|
||||
* a deadly signal */
|
||||
#if defined(FEAT_AUTOCHDIR)
|
||||
EXTERN int test_autochdir INIT(= FALSE);
|
||||
#endif
|
||||
#if defined(EXITFREE)
|
||||
EXTERN int entered_free_all_mem INIT(= FALSE);
|
||||
/* TRUE when in or after free_all_mem() */
|
||||
|
||||
@@ -164,6 +164,7 @@ SCRIPTS_GUI = test16.out
|
||||
# Keep test_alot*.res as the last one, sort the others.
|
||||
NEW_TESTS = test_arglist.res \
|
||||
test_assert.res \
|
||||
test_autochdir \
|
||||
test_backspace_opt.res \
|
||||
test_cdo.res \
|
||||
test_channel.res \
|
||||
|
||||
17
src/testdir/test_autochdir.vim
Normal file
17
src/testdir/test_autochdir.vim
Normal file
@@ -0,0 +1,17 @@
|
||||
" Test 'autochdir' behavior
|
||||
|
||||
if !exists("+autochdir")
|
||||
finish
|
||||
endif
|
||||
|
||||
func Test_set_filename()
|
||||
call test_autochdir()
|
||||
set acd
|
||||
new
|
||||
w samples/Xtest
|
||||
call assert_equal("Xtest", expand('%'))
|
||||
call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', ''))
|
||||
bwipe!
|
||||
set noacd
|
||||
call delete('samples/Xtest')
|
||||
endfunc
|
||||
@@ -758,6 +758,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2015,
|
||||
/**/
|
||||
2014,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user