Skip to content

Commit

Permalink
Merge pull request #5042 from bfredl/unnamedunnamedplus
Browse files Browse the repository at this point in the history
clipboard: make v:register=='+' when clipboard=unnamed,unnamedplus
  • Loading branch information
bfredl committed Jul 13, 2016
2 parents 5ea4d58 + 6ea2bde commit be531ab
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
7 changes: 3 additions & 4 deletions runtime/autoload/provider/clipboard.vim
Expand Up @@ -65,11 +65,10 @@ endif
let s:clipboard = {}

function! s:clipboard.get(reg)
let reg = a:reg == '"' ? '+' : a:reg
if s:selections[reg].owner > 0
return s:selections[reg].data
if s:selections[a:reg].owner > 0
return s:selections[a:reg].data
end
return s:try_cmd(s:paste[reg])
return s:try_cmd(s:paste[a:reg])
endfunction

function! s:clipboard.set(lines, regtype, reg)
Expand Down
2 changes: 1 addition & 1 deletion src/nvim/ops.c
Expand Up @@ -5452,7 +5452,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)

yankreg_T *target;
if (cb_flags & CB_UNNAMEDPLUS) {
*name = cb_flags & CB_UNNAMED ? '"': '+';
*name = (cb_flags & CB_UNNAMED && writing) ? '"': '+';
target = &y_regs[PLUS_REGISTER];
} else {
*name = '*';
Expand Down
2 changes: 2 additions & 0 deletions test/functional/clipboard/clipboard_provider_spec.lua
Expand Up @@ -308,6 +308,7 @@ describe('clipboard usage', function()
end)

it('links the "+ and unnamed registers', function()
eq('+', eval('v:register'))
insert("one two")
feed('^"+dwdw"+P')
expect('two')
Expand Down Expand Up @@ -335,6 +336,7 @@ describe('clipboard usage', function()
eq({{'really unnamed', ''}, 'V'}, eval("g:test_clip['*']"))

-- unnamedplus takes predecence when pasting
eq('+', eval('v:register'))
execute("let g:test_clip['+'] = ['the plus','']")
execute("let g:test_clip['*'] = ['the star','']")
feed("p")
Expand Down
5 changes: 2 additions & 3 deletions test/functional/fixtures/autoload/provider/clipboard.vim
Expand Up @@ -9,13 +9,12 @@ 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[reg][0]
return g:test_clip[a:reg][0]
else
" behave like VIMENC clipboard
return g:test_clip[reg]
return g:test_clip[a:reg]
end
endfunction

Expand Down

0 comments on commit be531ab

Please sign in to comment.