mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 00:08:19 +00:00
clipboard: support clipboard=unnamedplus,unnamed
This commit is contained in:
@@ -232,12 +232,15 @@ describe('clipboard usage', function()
|
||||
expect('words')
|
||||
eq({{'words'}, 'v'}, eval("g:test_clip['*']"))
|
||||
|
||||
-- "+ shouldn't have changed
|
||||
eq({''}, eval("g:test_clip['+']"))
|
||||
|
||||
execute("let g:test_clip['*'] = ['linewise stuff','']")
|
||||
feed('p')
|
||||
expect([[
|
||||
words
|
||||
linewise stuff]])
|
||||
end)
|
||||
end)
|
||||
|
||||
it('does not clobber "0 when pasting', function()
|
||||
insert('a line')
|
||||
@@ -284,6 +287,50 @@ describe('clipboard usage', function()
|
||||
|
||||
end)
|
||||
|
||||
describe('with clipboard=unnamedplus', function()
|
||||
before_each(function()
|
||||
execute('set clipboard=unnamedplus')
|
||||
end)
|
||||
|
||||
it('links the "+ and unnamed registers', function()
|
||||
insert("one two")
|
||||
feed('^"+dwdw"+P')
|
||||
expect('two')
|
||||
eq({{'two'}, 'v'}, eval("g:test_clip['+']"))
|
||||
|
||||
-- "* shouldn't have changed
|
||||
eq({''}, eval("g:test_clip['*']"))
|
||||
|
||||
execute("let g:test_clip['+'] = ['three']")
|
||||
feed('p')
|
||||
expect('twothree')
|
||||
end)
|
||||
|
||||
it('and unnamed, yanks to both', function()
|
||||
execute('set clipboard=unnamedplus,unnamed')
|
||||
insert([[
|
||||
really unnamed
|
||||
text]])
|
||||
feed('ggdd"*p"+p')
|
||||
expect([[
|
||||
text
|
||||
really unnamed
|
||||
really unnamed]])
|
||||
eq({{'really unnamed', ''}, 'V'}, eval("g:test_clip['+']"))
|
||||
eq({{'really unnamed', ''}, 'V'}, eval("g:test_clip['*']"))
|
||||
|
||||
-- unnamedplus takes predecence when pasting
|
||||
execute("let g:test_clip['+'] = ['the plus','']")
|
||||
execute("let g:test_clip['*'] = ['the star','']")
|
||||
feed("p")
|
||||
expect([[
|
||||
text
|
||||
really unnamed
|
||||
really unnamed
|
||||
the plus]])
|
||||
end)
|
||||
end)
|
||||
|
||||
it('supports :put', function()
|
||||
insert("a line")
|
||||
execute("let g:test_clip['*'] = ['some text']")
|
||||
|
@@ -9,16 +9,22 @@ function! s:methods.get(reg)
|
||||
if g:cliperror
|
||||
return 0
|
||||
end
|
||||
let reg = a:reg == '"' ? '+' : a:reg
|
||||
if g:cliplossy
|
||||
" behave like pure text clipboard
|
||||
return g:test_clip[a:reg][0]
|
||||
return g:test_clip[reg][0]
|
||||
else
|
||||
"behave like VIMENC clipboard
|
||||
return g:test_clip[a:reg]
|
||||
" behave like VIMENC clipboard
|
||||
return g:test_clip[reg]
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! s:methods.set(lines, regtype, reg)
|
||||
if a:reg == '"'
|
||||
call s:methods.set(a:lines,a:regtype,'+')
|
||||
call s:methods.set(a:lines,a:regtype,'*')
|
||||
return 0
|
||||
end
|
||||
let g:test_clip[a:reg] = [a:lines, a:regtype]
|
||||
endfunction
|
||||
|
||||
|
Reference in New Issue
Block a user