mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
Merge pull request #5042 from bfredl/unnamedunnamedplus
clipboard: make v:register=='+' when clipboard=unnamed,unnamedplus
This commit is contained in:
commit
be531aba77
@ -65,11 +65,10 @@ endif
|
|||||||
let s:clipboard = {}
|
let s:clipboard = {}
|
||||||
|
|
||||||
function! s:clipboard.get(reg)
|
function! s:clipboard.get(reg)
|
||||||
let reg = a:reg == '"' ? '+' : a:reg
|
if s:selections[a:reg].owner > 0
|
||||||
if s:selections[reg].owner > 0
|
return s:selections[a:reg].data
|
||||||
return s:selections[reg].data
|
|
||||||
end
|
end
|
||||||
return s:try_cmd(s:paste[reg])
|
return s:try_cmd(s:paste[a:reg])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:clipboard.set(lines, regtype, reg)
|
function! s:clipboard.set(lines, regtype, reg)
|
||||||
|
@ -5452,7 +5452,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
|
|||||||
|
|
||||||
yankreg_T *target;
|
yankreg_T *target;
|
||||||
if (cb_flags & CB_UNNAMEDPLUS) {
|
if (cb_flags & CB_UNNAMEDPLUS) {
|
||||||
*name = cb_flags & CB_UNNAMED ? '"': '+';
|
*name = (cb_flags & CB_UNNAMED && writing) ? '"': '+';
|
||||||
target = &y_regs[PLUS_REGISTER];
|
target = &y_regs[PLUS_REGISTER];
|
||||||
} else {
|
} else {
|
||||||
*name = '*';
|
*name = '*';
|
||||||
|
@ -308,6 +308,7 @@ describe('clipboard usage', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('links the "+ and unnamed registers', function()
|
it('links the "+ and unnamed registers', function()
|
||||||
|
eq('+', eval('v:register'))
|
||||||
insert("one two")
|
insert("one two")
|
||||||
feed('^"+dwdw"+P')
|
feed('^"+dwdw"+P')
|
||||||
expect('two')
|
expect('two')
|
||||||
@ -335,6 +336,7 @@ describe('clipboard usage', function()
|
|||||||
eq({{'really unnamed', ''}, 'V'}, eval("g:test_clip['*']"))
|
eq({{'really unnamed', ''}, 'V'}, eval("g:test_clip['*']"))
|
||||||
|
|
||||||
-- unnamedplus takes predecence when pasting
|
-- unnamedplus takes predecence when pasting
|
||||||
|
eq('+', eval('v:register'))
|
||||||
execute("let g:test_clip['+'] = ['the plus','']")
|
execute("let g:test_clip['+'] = ['the plus','']")
|
||||||
execute("let g:test_clip['*'] = ['the star','']")
|
execute("let g:test_clip['*'] = ['the star','']")
|
||||||
feed("p")
|
feed("p")
|
||||||
|
@ -9,13 +9,12 @@ function! s:methods.get(reg)
|
|||||||
if g:cliperror
|
if g:cliperror
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
let reg = a:reg == '"' ? '+' : a:reg
|
|
||||||
if g:cliplossy
|
if g:cliplossy
|
||||||
" behave like pure text clipboard
|
" behave like pure text clipboard
|
||||||
return g:test_clip[reg][0]
|
return g:test_clip[a:reg][0]
|
||||||
else
|
else
|
||||||
" behave like VIMENC clipboard
|
" behave like VIMENC clipboard
|
||||||
return g:test_clip[reg]
|
return g:test_clip[a:reg]
|
||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user