From 36290a2ebd3d49fa43f90fbdbf32e0cbe4f76d87 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 17 Oct 2021 22:04:53 +0800 Subject: vim-patch:8.2.1411: when splitting a window localdir is copied but prevdir is not Problem: when splitting a window localdir is copied but prevdir is not. Solution: Also copy prevdir. (closes vim/vim#6667) https://github.com/vim/vim/commit/a9a47d157ab1946d1e286c9695bc68d71305af68 --- src/nvim/testdir/test_cd.vim | 9 +++++++++ src/nvim/window.c | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_cd.vim b/src/nvim/testdir/test_cd.vim index 36135b52ce..0bba321ee2 100644 --- a/src/nvim/testdir/test_cd.vim +++ b/src/nvim/testdir/test_cd.vim @@ -192,6 +192,15 @@ func Test_prev_dir() call delete('Xdir', 'rf') endfunc +func Test_lcd_split() + let curdir = getcwd() + lcd .. + split + lcd - + call assert_equal(curdir, getcwd()) + quit! +endfunc + func Test_cd_from_non_existing_dir() CheckNotMSWindows diff --git a/src/nvim/window.c b/src/nvim/window.c index db71512a3b..b841b219b2 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1463,6 +1463,8 @@ static void win_init(win_T *newp, win_T *oldp, int flags) } newp->w_localdir = (oldp->w_localdir == NULL) ? NULL : vim_strsave(oldp->w_localdir); + newp->w_prevdir = (oldp->w_prevdir == NULL) + ? NULL : vim_strsave(oldp->w_prevdir); // copy tagstack and folds for (i = 0; i < oldp->w_tagstacklen; i++) { -- cgit