diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-13 08:40:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-13 08:40:06 +0800 |
commit | f76e1ac92eda9cb364a9de49422b45a035256ca6 (patch) | |
tree | 6cc375a9410c04d21392e5877513de831cf2f81f /test | |
parent | a6d63591f1fc61d570b646306d7c259b5ec2cace (diff) | |
download | rneovim-f76e1ac92eda9cb364a9de49422b45a035256ca6.tar.gz rneovim-f76e1ac92eda9cb364a9de49422b45a035256ca6.tar.bz2 rneovim-f76e1ac92eda9cb364a9de49422b45a035256ca6.zip |
vim-patch:9.0.1546: some commands for opening a file don't use 'switchbuf' (#23600)
Problem: Some commands for opening a file don't use 'switchbuf'.
Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan,
closes vim/vim#12383, closes vim/vim#12381)
https://github.com/vim/vim/commit/54be5fb382d2bf25fd1b17ddab8b21f599019b81
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_gf.vim | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/old/testdir/test_gf.vim b/test/old/testdir/test_gf.vim index f09dbd72ce..9824c8276e 100644 --- a/test/old/testdir/test_gf.vim +++ b/test/old/testdir/test_gf.vim @@ -300,4 +300,65 @@ func Test_gf_subdirs_wildcard() set path& endfunc +" Test for 'switchbuf' with gf and gF commands +func Test_gf_switchbuf() + call writefile(repeat(["aaa"], 10), "Xtest1", 'D') + edit Xtest1 + new + call setline(1, ['Xtest1']) + + " Test for 'useopen' + set switchbuf=useopen + call cursor(1, 1) + exe "normal \<C-W>f" + call assert_equal([2, 2], [winnr(), winnr('$')]) + close + + " If the file is opened in another tabpage, then it should not be considered + tabedit Xtest1 + tabfirst + exe "normal \<C-W>f" + call assert_equal([1, 2], [winnr(), winnr('$')]) + call assert_equal([1, 2], [tabpagenr(), tabpagenr('$')]) + close + + " Test for 'usetab' + set switchbuf=usetab + exe "normal \<C-W>f" + call assert_equal([1, 1], [winnr(), winnr('$')]) + call assert_equal([2, 2], [tabpagenr(), tabpagenr('$')]) + %bw! + + " Test for CTRL-W_F with 'useopen' + set isfname-=: + call setline(1, ['Xtest1:5']) + set switchbuf=useopen + split +1 Xtest1 + wincmd b + exe "normal \<C-W>F" + call assert_equal([1, 2], [winnr(), winnr('$')]) + call assert_equal(5, line('.')) + close + + " If the file is opened in another tabpage, then it should not be considered + tabedit +1 Xtest1 + tabfirst + exe "normal \<C-W>F" + call assert_equal([1, 2], [winnr(), winnr('$')]) + call assert_equal(5, line('.')) + call assert_equal([1, 2], [tabpagenr(), tabpagenr('$')]) + close + + " Test for CTRL_W_F with 'usetab' + set switchbuf=usetab + exe "normal \<C-W>F" + call assert_equal([2, 2], [tabpagenr(), tabpagenr('$')]) + call assert_equal([1, 1], [winnr(), winnr('$')]) + call assert_equal(5, line('.')) + + set switchbuf= + set isfname& + %bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |