diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2015-07-15 18:06:35 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-07-20 20:24:28 -0400 |
commit | 8047570b708c27b68e9a3a50c11de932c3eeab41 (patch) | |
tree | a004170cd442f19404965cd2d06966cd4fe12930 | |
parent | c30f2ac25de1235e4cd743fe1a16be20c14e140b (diff) | |
download | rneovim-8047570b708c27b68e9a3a50c11de932c3eeab41.tar.gz rneovim-8047570b708c27b68e9a3a50c11de932c3eeab41.tar.bz2 rneovim-8047570b708c27b68e9a3a50c11de932c3eeab41.zip |
clipboard: add tests for error fallback and middleclick paste
-rw-r--r-- | test/functional/clipboard/clipboard_provider_spec.lua | 53 | ||||
-rw-r--r-- | test/functional/fixtures/autoload/provider/clipboard.vim (renamed from test/functional/clipboard/autoload/provider/clipboard.vim) | 4 |
2 files changed, 56 insertions, 1 deletions
diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua index 9282a66240..f6d6188d82 100644 --- a/test/functional/clipboard/clipboard_provider_spec.lua +++ b/test/functional/clipboard/clipboard_provider_spec.lua @@ -92,7 +92,7 @@ end) describe('clipboard usage', function() before_each(function() clear() - execute('let &rtp = "test/functional/clipboard,".&rtp') + execute('let &rtp = "test/functional/fixtures,".&rtp') execute('call getreg("*")') -- force load of provider end) @@ -197,6 +197,17 @@ describe('clipboard usage', function() expect('some more') end) + it('pastes unnamed register if the provider fails', function() + insert('the text') + feed('yy') + execute("let g:cliperror = 1") + feed('"*p') + expect([[ + the text + the text]]) + end) + + describe('with clipboard=unnamed', function() -- the basic behavior of unnamed register should be the same -- even when handled by clipboard provider @@ -261,6 +272,16 @@ describe('clipboard usage', function() expect("indeed star") end) + it('unamed operations work even if the provider fails', function() + insert('the text') + feed('yy') + execute("let g:cliperror = 1") + feed('p') + expect([[ + the text + the text]]) + end) + end) it('supports :put', function() @@ -335,4 +356,34 @@ describe('clipboard usage', function() 'Howdy!', }, 'v'}, eval("g:test_clip['*']")) end) + + it('handles middleclick correctly', function() + local screen = Screen.new(30, 5) + screen:attach() + insert([[ + the source + a target]]) + feed('gg"*ywwyw') + -- clicking depends on the exact visual layout, so expect it: + screen:expect([[ + the ^source | + a target | + ~ | + ~ | + | + ]], nil, {{bold = true, foreground = Screen.colors.Blue}}) + + feed('<MiddleMouse><0,1>') + expect([[ + the source + the a target]]) + + -- on error, fall back to unnamed register + execute("let g:cliperror = 1") + feed('<MiddleMouse><6,1>') + expect([[ + the source + the a sourcetarget]]) + end) + end) diff --git a/test/functional/clipboard/autoload/provider/clipboard.vim b/test/functional/fixtures/autoload/provider/clipboard.vim index d88b68464e..a28484169a 100644 --- a/test/functional/clipboard/autoload/provider/clipboard.vim +++ b/test/functional/fixtures/autoload/provider/clipboard.vim @@ -3,8 +3,12 @@ let g:test_clip = { '+': [''], '*': [''], } let s:methods = {} let g:cliplossy = 0 +let g:cliperror = 0 function! s:methods.get(reg) + if g:cliperror + return 0 + end if g:cliplossy " behave like pure text clipboard return g:test_clip[a:reg][0] |