Merge pull request #5042 from bfredl/unnamedunnamedplus

clipboard: make v:register=='+' when clipboard=unnamed,unnamedplus
This commit is contained in:
Björn Linse 2016-07-13 10:11:30 +02:00 committed by GitHub
commit be531aba77
4 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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 = '*';

View File

@ -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")

View File

@ -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