mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test/clipboard: more clipboard test cleanups
This commit is contained in:
parent
7422843f5c
commit
db92fcdba3
@ -2,8 +2,16 @@ let g:test_clip = { '+': [''], '*': [''], }
|
|||||||
|
|
||||||
let s:methods = {}
|
let s:methods = {}
|
||||||
|
|
||||||
|
let g:cliplossy = 0
|
||||||
|
|
||||||
function! s:methods.get(reg)
|
function! s:methods.get(reg)
|
||||||
return g:test_clip[a:reg]
|
if g:cliplossy
|
||||||
|
" behave like pure text clipboard
|
||||||
|
return g:test_clip[a:reg][0]
|
||||||
|
else
|
||||||
|
"behave like VIMENC clipboard
|
||||||
|
return g:test_clip[a:reg]
|
||||||
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:methods.set(lines, regtype, reg)
|
function! s:methods.set(lines, regtype, reg)
|
||||||
|
@ -6,13 +6,7 @@ local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
|||||||
local execute, expect, eq, eval = helpers.execute, helpers.expect, helpers.eq, helpers.eval
|
local execute, expect, eq, eval = helpers.execute, helpers.expect, helpers.eq, helpers.eval
|
||||||
local nvim, run, stop, restart = helpers.nvim, helpers.run, helpers.stop, helpers.restart
|
local nvim, run, stop, restart = helpers.nvim, helpers.run, helpers.stop, helpers.restart
|
||||||
|
|
||||||
local function reset()
|
local function basic_register_test(noblock)
|
||||||
clear()
|
|
||||||
execute('let &rtp = "test/functional/clipboard,".&rtp')
|
|
||||||
execute('call getreg("*")') -- force load of provider
|
|
||||||
end
|
|
||||||
|
|
||||||
local function basic_register_test()
|
|
||||||
insert("some words")
|
insert("some words")
|
||||||
|
|
||||||
feed('^dwP')
|
feed('^dwP')
|
||||||
@ -60,20 +54,41 @@ local function basic_register_test()
|
|||||||
expect([[
|
expect([[
|
||||||
, stuff and some more
|
, stuff and some more
|
||||||
some textsome some text, stuff and some more]])
|
some textsome some text, stuff and some more]])
|
||||||
reset()
|
|
||||||
|
feed('ggw<c-v>jwyggP')
|
||||||
|
if noblock then
|
||||||
|
expect([[
|
||||||
|
stuf
|
||||||
|
me t
|
||||||
|
, stuff and some more
|
||||||
|
some textsome some text, stuff and some more]])
|
||||||
|
else
|
||||||
|
expect([[
|
||||||
|
stuf, stuff and some more
|
||||||
|
me tsome textsome some text, stuff and some more]])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('clipboard usage', function()
|
describe('the unnamed register', function()
|
||||||
before_each(reset)
|
before_each(clear)
|
||||||
|
it('works without provider', function()
|
||||||
it("works", function()
|
|
||||||
basic_register_test()
|
basic_register_test()
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
-- "* and unnamed should function as independent registers
|
describe('clipboard usage', function()
|
||||||
|
before_each(function()
|
||||||
|
clear()
|
||||||
|
execute('let &rtp = "test/functional/clipboard,".&rtp')
|
||||||
|
execute('call getreg("*")') -- force load of provider
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('has independent "* and unnamed registers per default', function()
|
||||||
insert("some words")
|
insert("some words")
|
||||||
feed('^"*dwdw"*P')
|
feed('^"*dwdw"*P')
|
||||||
expect('some ')
|
expect('some ')
|
||||||
eq({{'some '}, 'v'}, eval("g:test_clip['*']"))
|
eq({{'some '}, 'v'}, eval("g:test_clip['*']"))
|
||||||
|
eq('words', eval("getreg('\"', 1)"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('supports separate "* and "+ when the provider supports it', function()
|
it('supports separate "* and "+ when the provider supports it', function()
|
||||||
@ -169,24 +184,37 @@ describe('clipboard usage', function()
|
|||||||
expect('some more')
|
expect('some more')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('supports clipboard=unnamed', function()
|
describe('with clipboard=unnamed', function()
|
||||||
-- the basic behavior of unnamed register should be the same
|
-- the basic behavior of unnamed register should be the same
|
||||||
-- even when handled by clipboard provider
|
-- even when handled by clipboard provider
|
||||||
execute('set clipboard=unnamed')
|
before_each(function()
|
||||||
basic_register_test()
|
execute('set clipboard=unnamed')
|
||||||
|
end)
|
||||||
|
|
||||||
-- with cb=unnamed, "* and unnamed will be the same register
|
it('works', function()
|
||||||
execute('set clipboard=unnamed')
|
basic_register_test()
|
||||||
insert("some words")
|
end)
|
||||||
feed('^"*dwdw"*P')
|
|
||||||
expect('words')
|
|
||||||
eq({{'words'}, 'v'}, eval("g:test_clip['*']"))
|
|
||||||
|
|
||||||
execute("let g:test_clip['*'] = ['linewise stuff','']")
|
it('works with pure text clipboard', function()
|
||||||
feed('p')
|
execute("let g:cliplossy = 1")
|
||||||
expect([[
|
-- expect failure for block mode
|
||||||
words
|
basic_register_test(true)
|
||||||
linewise stuff]])
|
end)
|
||||||
|
|
||||||
|
it('links the "* and unnamed registers', function()
|
||||||
|
-- with cb=unnamed, "* and unnamed will be the same register
|
||||||
|
execute('set clipboard=unnamed')
|
||||||
|
insert("some words")
|
||||||
|
feed('^"*dwdw"*P')
|
||||||
|
expect('words')
|
||||||
|
eq({{'words'}, 'v'}, eval("g:test_clip['*']"))
|
||||||
|
|
||||||
|
execute("let g:test_clip['*'] = ['linewise stuff','']")
|
||||||
|
feed('p')
|
||||||
|
expect([[
|
||||||
|
words
|
||||||
|
linewise stuff]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('supports :put', function()
|
it('supports :put', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user