From 59487e18a7b26d8cea2c766ad5fbe17a152a5d11 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Fri, 1 Jul 2016 11:34:43 +0200 Subject: vim-patch:7.4.1716 Problem: 'autochdir' doesn't work for the first file. (Rob Hoelz) Solution: Call DO_AUTOCHDIR after startup. (Christian Brabandt) https://github.com/vim/vim/commit/baec5c1768098f9dd867b465aaabfdfb294f10c2 --- src/nvim/main.c | 3 +++ src/nvim/version.c | 1 + 2 files changed, 4 insertions(+) diff --git a/src/nvim/main.c b/src/nvim/main.c index ba545c0815..a876a0ad21 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -507,6 +507,9 @@ int main(int argc, char **argv) no_wait_return = FALSE; starting = 0; + // 'autochdir' has been postponed. + do_autochdir(); + /* start in insert mode */ if (p_im) need_start_insertmode = TRUE; diff --git a/src/nvim/version.c b/src/nvim/version.c index b2c6b332d1..aa3a34b3df 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -86,6 +86,7 @@ static int included_patches[] = { 1755, 1753, 1728, + 1716, 1695, 1654, 1652, -- cgit From 0d9593ff14a1d59b58816c830306daa1956d1220 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Fri, 1 Jul 2016 20:27:56 +0200 Subject: Tests: check 'autochdir' on startup --- test/functional/options/autochdir_spec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/functional/options/autochdir_spec.lua diff --git a/test/functional/options/autochdir_spec.lua b/test/functional/options/autochdir_spec.lua new file mode 100644 index 0000000000..0e293761ad --- /dev/null +++ b/test/functional/options/autochdir_spec.lua @@ -0,0 +1,18 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local eq = helpers.eq +local getcwd = helpers.funcs.getcwd + +describe("'autochdir'", function() + it('given on the shell gets processed properly', function() + local targetdir = 'test/functional/fixtures' + + -- By default 'autochdir' is off, thus getcwd() returns the repo root. + clear(targetdir..'/tty-test.c') + local rootdir = getcwd() + + -- With 'autochdir' on, we should get the directory of tty-test.c. + clear('--cmd', 'set autochdir', targetdir..'/tty-test.c') + eq(rootdir..'/'..targetdir, getcwd()) + end) +end) -- cgit