clipboard: setreg("*") with clipboard=unnamed #9954

Helped-by: Björn Linse <bjorn.linse@gmail.com>
fix #5646
This commit is contained in:
Justin M. Keyes 2019-04-28 21:06:24 +02:00 committed by GitHub
parent c76c798bf6
commit 8aca932aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -5616,6 +5616,9 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing)
if (explicit_cb_reg) {
target = &y_regs[*name == '*' ? STAR_REGISTER : PLUS_REGISTER];
if (writing && (cb_flags & (*name == '*' ? CB_UNNAMED : CB_UNNAMEDPLUS))) {
clipboard_needs_update = false;
}
goto end;
} else { // unnamed register: "implicit" clipboard
if (writing && clipboard_delay_update) {

View File

@ -236,7 +236,7 @@ describe('clipboard', function()
end)
end)
describe('clipboard', function()
describe('clipboard (with fake clipboard.vim)', function()
local function reset(...)
clear('--cmd', 'let &rtp = "test/functional/fixtures,".&rtp', ...)
end
@ -664,4 +664,20 @@ describe('clipboard', function()
the a sourcetarget]])
end)
it('setreg("*") with clipboard=unnamed #5646', function()
source([=[
function! Paste_without_yank(direction) range
let [reg_save,regtype_save] = [getreg('*'), getregtype('*')]
normal! gvp
call setreg('*', reg_save, regtype_save)
endfunction
xnoremap p :call Paste_without_yank('p')<CR>
set clipboard=unnamed
]=])
insert('some words')
feed('gg0yiw')
feed('wviwp')
expect('some some')
eq('some', eval('getreg("*")'))
end)
end)