summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_visual.vim
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2022-05-06 11:45:09 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-06 11:45:09 +0100
commit509142ab7a9db32114b6d0949722b9133c9c22f2 (patch)
tree45b4cfc0fbae41deda1227b38075a40737660ac4 /src/testdir/test_visual.vim
parent434725cc4cbbadafc82954178f55864741455cdb (diff)
patch 8.2.4881: "P" in Visual mode still changes some registersv8.2.4881
Problem: "P" in Visual mode still changes some registers. Solution: Make "P" in Visual mode not change any register. (Shougo Matsushita, closes #10349)
Diffstat (limited to 'src/testdir/test_visual.vim')
-rw-r--r--src/testdir/test_visual.vim80
1 files changed, 60 insertions, 20 deletions
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 3fbd5c7e4e..abc8265bdb 100644
--- 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