From 0c43479979547ed84b2a898dcc7816767333cc80 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 10 Dec 2016 18:33:55 +0900 Subject: vim-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 vim/vim#777, closes vim/vim#803) Add test_autochdir() to enable 'acd' before "starting" is reset. https://github.com/vim/vim/commit/5c71994f4ee5f87d4cce990dbc9684c70b1e108b --- src/nvim/buffer.c | 2 +- src/nvim/eval.c | 6 ++++++ src/nvim/eval.lua | 1 + src/nvim/ex_cmds.c | 8 +++++++- src/nvim/globals.h | 2 ++ src/nvim/testdir/test_alot.vim | 1 + src/nvim/testdir/test_autochdir.vim | 17 +++++++++++++++++ src/nvim/version.c | 2 +- 8 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/nvim/testdir/test_autochdir.vim (limited to 'src/nvim') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index d9fdc80c60..58ec5dc377 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1330,7 +1330,7 @@ void enter_buffer(buf_T *buf) void do_autochdir(void) { if (p_acd) { - if (starting == 0 + if ((starting == 0 || test_autochdir) && curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK) { shorten_fnames(true); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 32e1991742..6bcc3ca986 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -17159,6 +17159,12 @@ static void f_tempname(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_string = vim_tempname(); } +// "test_autochdir()" function +static void f_test_autochdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + test_autochdir = TRUE; +} + // "termopen(cmd[, cwd])" function static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) { diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 980a8d2326..9022103c7d 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -301,6 +301,7 @@ return { tan={args=1, func="float_op_wrapper", data="&tan"}, tanh={args=1, func="float_op_wrapper", data="&tanh"}, tempname={}, + test_autochdir={}, termopen={args={1, 2}}, test={args=1}, timer_start={args={2,3}}, diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index fcaf17a0fc..b1a17e8c44 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1611,6 +1611,7 @@ int do_write(exarg_T *eap) int retval = FAIL; char_u *free_fname = NULL; buf_T *alt_buf = NULL; + int name_was_missing; if (not_writing()) /* check 'write' option */ return FAIL; @@ -1734,6 +1735,7 @@ int do_write(exarg_T *eap) fname = curbuf->b_sfname; } + name_was_missing = curbuf->b_ffname == NULL; retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2, eap, eap->append, eap->forceit, TRUE, FALSE); @@ -1743,7 +1745,11 @@ int do_write(exarg_T *eap) curbuf->b_p_ro = FALSE; redraw_tabline = TRUE; } - /* 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(); } } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index fbffc2d44d..bfc6a14ad8 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -641,6 +641,8 @@ EXTERN volatile int full_screen INIT(= FALSE); /* TRUE when doing full-screen output * otherwise only writing some messages */ +EXTERN int test_autochdir INIT(= FALSE); + EXTERN int restricted INIT(= FALSE); // TRUE when started in restricted mode (-Z) EXTERN int secure INIT(= FALSE); diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 818ff7cf54..54a2795d4a 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -3,6 +3,7 @@ source test_assign.vim source test_autocmd.vim +source test_autochdir.vim source test_cursor_func.vim source test_ex_undo.vim source test_expr.vim diff --git a/src/nvim/testdir/test_autochdir.vim b/src/nvim/testdir/test_autochdir.vim new file mode 100644 index 0000000000..f52e2e668a --- /dev/null +++ b/src/nvim/testdir/test_autochdir.vim @@ -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 diff --git a/src/nvim/version.c b/src/nvim/version.c index 9f2b7a26c3..6659eedabb 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -425,7 +425,7 @@ static int included_patches[] = { // 2018, // 2017, // 2016 NA - // 2015, + 2015, 2014, 2013, 2012, -- cgit From 6ba3b8538245d1176b869734c76f2688709cf106 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 10 Dec 2016 18:49:33 +0900 Subject: vim-patch:6f1d9a Updated runtime files. https://github.com/vim/vim/commit/6f1d9a096bf22d50c727dca73abbfb8e3ff55176 --- src/nvim/eval.c | 2 +- src/nvim/globals.h | 2 +- src/nvim/testdir/Makefile | 3 ++- src/nvim/testdir/test_alot.vim | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6bcc3ca986..48b51f1e9f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -17162,7 +17162,7 @@ static void f_tempname(typval_T *argvars, typval_T *rettv, FunPtr fptr) // "test_autochdir()" function static void f_test_autochdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - test_autochdir = TRUE; + test_autochdir = true; } // "termopen(cmd[, cwd])" function diff --git a/src/nvim/globals.h b/src/nvim/globals.h index bfc6a14ad8..db4600ee4e 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -641,7 +641,7 @@ EXTERN volatile int full_screen INIT(= FALSE); /* TRUE when doing full-screen output * otherwise only writing some messages */ -EXTERN int test_autochdir INIT(= FALSE); +EXTERN int test_autochdir INIT(= false); EXTERN int restricted INIT(= FALSE); // TRUE when started in restricted mode (-Z) diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 84a0c0b889..5bb7fd1dda 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -30,6 +30,7 @@ SCRIPTS := \ # Tests using runtest.vim.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS = \ + test_autochdir.res \ test_bufwintabinfo.res \ test_cmdline.res \ test_cscope.res \ @@ -43,8 +44,8 @@ NEW_TESTS = \ test_quickfix.res \ test_signs.res \ test_syntax.res \ - test_usercommands.res \ test_timers.res \ + test_usercommands.res \ test_viml.res \ test_visual.res \ test_window_id.res \ diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 54a2795d4a..818ff7cf54 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -3,7 +3,6 @@ source test_assign.vim source test_autocmd.vim -source test_autochdir.vim source test_cursor_func.vim source test_ex_undo.vim source test_expr.vim -- cgit From 097c8dcccab1f66098e0096c7590ea4eb446dd56 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 4 Jan 2017 05:22:32 +0100 Subject: refactor: Remove VimL function `test_autochdir()` - Eliminate global test_autochdir. - Eliminate VimL function test_autochdir() - Use a lua test instead. Fails correctly after reverting 0c4347997954 / vim-patch:7.4.2015. --- src/nvim/buffer.c | 2 +- src/nvim/eval.c | 6 ------ src/nvim/eval.lua | 1 - src/nvim/globals.h | 2 -- src/nvim/testdir/Makefile | 1 - src/nvim/testdir/test_autochdir.vim | 17 ----------------- 6 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 src/nvim/testdir/test_autochdir.vim (limited to 'src/nvim') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 58ec5dc377..d9fdc80c60 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1330,7 +1330,7 @@ void enter_buffer(buf_T *buf) void do_autochdir(void) { if (p_acd) { - if ((starting == 0 || test_autochdir) + if (starting == 0 && curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK) { shorten_fnames(true); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 48b51f1e9f..32e1991742 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -17159,12 +17159,6 @@ static void f_tempname(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_string = vim_tempname(); } -// "test_autochdir()" function -static void f_test_autochdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - test_autochdir = true; -} - // "termopen(cmd[, cwd])" function static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) { diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 9022103c7d..980a8d2326 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -301,7 +301,6 @@ return { tan={args=1, func="float_op_wrapper", data="&tan"}, tanh={args=1, func="float_op_wrapper", data="&tanh"}, tempname={}, - test_autochdir={}, termopen={args={1, 2}}, test={args=1}, timer_start={args={2,3}}, diff --git a/src/nvim/globals.h b/src/nvim/globals.h index db4600ee4e..fbffc2d44d 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -641,8 +641,6 @@ EXTERN volatile int full_screen INIT(= FALSE); /* TRUE when doing full-screen output * otherwise only writing some messages */ -EXTERN int test_autochdir INIT(= false); - EXTERN int restricted INIT(= FALSE); // TRUE when started in restricted mode (-Z) EXTERN int secure INIT(= FALSE); diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 5bb7fd1dda..612071e2e2 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -30,7 +30,6 @@ SCRIPTS := \ # Tests using runtest.vim.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS = \ - test_autochdir.res \ test_bufwintabinfo.res \ test_cmdline.res \ test_cscope.res \ diff --git a/src/nvim/testdir/test_autochdir.vim b/src/nvim/testdir/test_autochdir.vim deleted file mode 100644 index f52e2e668a..0000000000 --- a/src/nvim/testdir/test_autochdir.vim +++ /dev/null @@ -1,17 +0,0 @@ -" 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 -- cgit From e43f7425ee3db238e3b38399307b8aefedfaacf2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 4 Jan 2017 05:32:46 +0100 Subject: refactor: Remove VimL function `test()` vim-patch:7.4.1838 --- src/nvim/eval.c | 8 -------- src/nvim/eval.lua | 1 - src/nvim/version.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 32e1991742..e5858b779a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -17249,14 +17249,6 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } -/* - * "test(list)" function: Just checking the walls... - */ -static void f_test(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - /* Used for unit testing. Change the code below to your liking. */ -} - static bool callback_from_typval(Callback *callback, typval_T *arg) { if (arg->v_type == VAR_PARTIAL && arg->vval.v_partial != NULL) { diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 980a8d2326..5fb99fecc6 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -302,7 +302,6 @@ return { tanh={args=1, func="float_op_wrapper", data="&tanh"}, tempname={}, termopen={args={1, 2}}, - test={args=1}, timer_start={args={2,3}}, timer_stop={args=1}, tolower={args=1}, diff --git a/src/nvim/version.c b/src/nvim/version.c index 6659eedabb..06ddbd5306 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -602,7 +602,7 @@ static int included_patches[] = { 1841, 1840, // 1839, - // 1838, + 1838, 1837, 1836, 1835, -- cgit