Mercurial > vim
diff src/testdir/test_visual.vim @ 34497:7cc0b2479fad v9.1.0155
patch 9.1.0155: can only get getregion() from current buffer
Commit: https://github.com/vim/vim/commit/84bf6e658da51126bdd2e50af1f40cabd149343f
Author: Shougo Matsushita <Shougo.Matsu@gmail.com>
Date: Wed Mar 6 21:10:18 2024 +0100
patch 9.1.0155: can only get getregion() from current buffer
Problem: can only call getregion() for current buffer
Solution: Allow to retrieve selections from different buffers
(Shougo Matsushita)
closes: #14131
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 06 Mar 2024 21:45:03 +0100 |
parents | 125dcecbfa09 |
children | f9a0bf1e7505 |
line wrap: on
line diff
--- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -1747,7 +1747,7 @@ func Test_visual_getregion() #" using the wrong type call assert_fails(':echo "."->getpos()->getregion("$", [])', 'E1211:') - #" using a mark in another buffer + #" using a mark from another buffer to current buffer new VAR newbuf = bufnr() call setline(1, range(10)) @@ -1757,6 +1757,20 @@ func Test_visual_getregion() call assert_equal([], getregion(getpos('.'), getpos("'A"), {'type': 'v' })) call assert_equal([], getregion(getpos("'A"), getpos('.'), {'type': 'v' })) exe $':{newbuf}bwipe!' + + #" using a mark from another buffer to another buffer + new + VAR anotherbuf = bufnr() + call setline(1, range(10)) + normal! GmA + normal! GmB + wincmd p + call assert_equal([anotherbuf, 10, 1, 0], getpos("'A")) + call assert_equal(['9'], getregion(getpos("'B"), getpos("'A"), {'type': 'v' })) + exe $':{anotherbuf}bwipe!' + + #" using invalid buffer + call assert_equal([], getregion([10000, 10, 1, 0], [10000, 10, 1, 0])) END call v9.CheckLegacyAndVim9Success(lines) @@ -1907,4 +1921,18 @@ func Test_visual_getregion() call v9.CheckLegacyAndVim9Success(lines) endfunc +func Test_getregion_invalid_buf() + new + help + call cursor(5, 7) + norm! mA + call cursor(5, 18) + norm! mB + call assert_equal(['Move around:'], getregion(getpos("'A"), getpos("'B"))) + " close the help window + q + call assert_equal([], getregion(getpos("'A"), getpos("'B"))) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab