aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-05-06 19:26:28 +0800
committerGitHub <noreply@github.com>2022-05-06 19:26:28 +0800
commit7978660efb087583a1ac49c70588d72af80de6d7 (patch)
tree505dbb2a886447710408fb46522084da305f3628 /src/nvim/testdir
parent8bbeab9989d5f905ce2e4512e9967ee99d859f70 (diff)
downloadrneovim-7978660efb087583a1ac49c70588d72af80de6d7.tar.gz
rneovim-7978660efb087583a1ac49c70588d72af80de6d7.tar.bz2
rneovim-7978660efb087583a1ac49c70588d72af80de6d7.zip
vim-patch:8.2.4881: "P" in Visual mode still changes some registers (#18445)
Problem: "P" in Visual mode still changes some registers. Solution: Make "P" in Visual mode not change any register. (Shougo Matsushita, closes vim/vim#10349) https://github.com/vim/vim/commit/509142ab7a9db32114b6d0949722b9133c9c22f2
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_visual.vim80
1 files changed, 60 insertions, 20 deletions
diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim
index ae8f9ba70b..2b88deb813 100644
--- a/src/nvim/testdir/test_visual.vim
+++ b/src/nvim/testdir/test_visual.vim
@@ -1350,34 +1350,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