diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-05 22:33:42 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-05 22:33:42 +0200 |
commit | 002bc79991286934a9593b80635c27d4238cdfc4 (patch) | |
tree | 777b6a2574f8dfe4ac76552a0a8e44ba005e7961 /src/testdir/test_cd.vim | |
parent | 3fffa97159a427067b60c80ed4645e168cc5c4bd (diff) |
patch 8.2.0909: cannot go back to the previous local directoryv8.2.0909
Problem: Cannot go back to the previous local directory.
Solution: Add "tcd -" and "lcd -". (Yegappan Lakshmanan, closes #4362)
Diffstat (limited to 'src/testdir/test_cd.vim')
-rw-r--r-- | src/testdir/test_cd.vim | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/testdir/test_cd.vim b/src/testdir/test_cd.vim index ad25f3a32e..53f9c1081e 100644 --- a/src/testdir/test_cd.vim +++ b/src/testdir/test_cd.vim @@ -129,6 +129,69 @@ func Test_chdir_func() call delete('Xdir', 'rf') endfunc +" Test for changing to the previous directory '-' +func Test_prev_dir() + let topdir = getcwd() + call mkdir('Xdir/a/b/c', 'p') + + " Create a few tabpages and windows with different directories + new | only + tabnew | new + tabnew + tabfirst + cd Xdir + tabnext | wincmd t + tcd a + wincmd w + lcd b + tabnext + tcd a/b/c + + " Change to the previous directory twice in all the windows. + tabfirst + cd - | cd - + tabnext | wincmd t + tcd - | tcd - + wincmd w + lcd - | lcd - + tabnext + tcd - | tcd - + + " Check the directory of all the windows + tabfirst + call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) + tabnext | wincmd t + call assert_equal('a', fnamemodify(getcwd(), ':t')) + wincmd w + call assert_equal('b', fnamemodify(getcwd(), ':t')) + tabnext + call assert_equal('c', fnamemodify(getcwd(), ':t')) + + " Change to the previous directory using chdir() + tabfirst + call chdir("-") | call chdir("-") + tabnext | wincmd t + call chdir("-") | call chdir("-") + wincmd w + call chdir("-") | call chdir("-") + tabnext + call chdir("-") | call chdir("-") + + " Check the directory of all the windows + tabfirst + call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) + tabnext | wincmd t + call assert_equal('a', fnamemodify(getcwd(), ':t')) + wincmd w + call assert_equal('b', fnamemodify(getcwd(), ':t')) + tabnext + call assert_equal('c', fnamemodify(getcwd(), ':t')) + + only | tabonly + call chdir(topdir) + call delete('Xdir', 'rf') +endfunc + func Test_cd_completion() call mkdir('XComplDir1', 'p') call mkdir('XComplDir2', 'p') |