Mercurial > vim
diff src/testdir/test_visual.vim @ 28714:5eea8a249f86 v8.2.4881
patch 8.2.4881: "P" in Visual mode still changes some registers
Commit: https://github.com/vim/vim/commit/509142ab7a9db32114b6d0949722b9133c9c22f2
Author: Shougo Matsushita <Shougo.Matsu@gmail.com>
Date: Fri May 6 11:45:09 2022 +0100
patch 8.2.4881: "P" in Visual mode still changes some registers
Problem: "P" in Visual mode still changes some registers.
Solution: Make "P" in Visual mode not change any register. (Shougo
Matsushita, closes #10349)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 06 May 2022 13:00:03 +0200 |
parents | 40d844af56a5 |
children | aa44d5842d6c |
line wrap: on
line diff
--- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -1390,34 +1390,74 @@ func Test_visual_paste() call assert_equal('x', @-) call assert_equal('bazooxxf', getline(1)) - if has('clipboard') - " v_P does not overwrite unnamed register. + bwipe! +endfunc + +func Test_visual_paste_clipboard() + CheckFeature clipboard_working + + if has('gui') + " auto select feature breaks tests + set guioptions-=a + endif + + " v_P does not overwrite unnamed register. + call setline(1, ['xxxx']) + call setreg('"', 'foo') + call setreg('-', 'bar') + normal gg0vP + call assert_equal('foo', @") + call assert_equal('bar', @-) + call assert_equal('fooxxx', getline(1)) + normal $vP + call assert_equal('foo', @") + call assert_equal('bar', @-) + call assert_equal('fooxxfoo', getline(1)) + " Test with a different register as unnamed register. + call setline(2, ['baz']) + normal 2gg0"rD + call assert_equal('baz', @") + normal gg0vP + call assert_equal('baz', @") + call assert_equal('bar', @-) + call assert_equal('bazooxxfoo', getline(1)) + normal $vP + call assert_equal('baz', @") + call assert_equal('bar', @-) + call assert_equal('bazooxxfobaz', getline(1)) + + " Test for unnamed clipboard + set clipboard=unnamed + call setline(1, ['xxxx']) + call setreg('"', 'foo') + call setreg('-', 'bar') + call setreg('*', 'baz') + normal gg0vP + call assert_equal('foo', @") + call assert_equal('bar', @-) + call assert_equal('baz', @*) + call assert_equal('bazxxx', getline(1)) + + " Test for unnamedplus clipboard + if has('unnamedplus') + set clipboard=unnamedplus call setline(1, ['xxxx']) call setreg('"', 'foo') call setreg('-', 'bar') + call setreg('+', 'baz') normal gg0vP call assert_equal('foo', @") - call assert_equal('x', @-) - call assert_equal('fooxxx', getline(1)) - normal $vP - call assert_equal('foo', @") - call assert_equal('x', @-) - call assert_equal('fooxxfoo', getline(1)) - " Test with a different register as unnamed register. - call setline(2, ['baz']) - normal 2gg0"rD - call assert_equal('baz', @") - normal gg0vP - call assert_equal('baz', @") - call assert_equal('f', @-) - call assert_equal('bazooxxfoo', getline(1)) - normal $vP - call assert_equal('baz', @") - call assert_equal('o', @-) - call assert_equal('bazooxxfobaz', getline(1)) + call assert_equal('bar', @-) + call assert_equal('baz', @+) + call assert_equal('bazxxx', getline(1)) endif + set clipboard& + if has('gui') + set guioptions& + endif bwipe! endfunc + " vim: shiftwidth=2 sts=2 expandtab