Files
neovim/test/functional/fixtures/autoload/provider/clipboard.vim
Justin M. Keyes cc7e344f83 clipboard: remove start_batch_changes() in redir_write()
start_batch_changes() doesn't avoid invoking the clipboard
once-per-line, because the loop is actually in ex_echo(), which calls
redir_write() for each message. But we've already entered
start_batch_changes() by then, so that was never the problem.

    redir_write at /home/vagrant/old.neovim/build/../src/nvim/message.c:2523
    msg_puts_attr_len at /home/vagrant/old.neovim/build/../src/nvim/message.c:1600
    msg_outtrans_len_attr at /home/vagrant/old.neovim/build/../src/nvim/message.c:1221
    ex_echo at /home/vagrant/old.neovim/build/../src/nvim/eval.c:19433
    do_one_cmd at /home/vagrant/old.neovim/build/../src/nvim/ex_docmd.c:2242

Trying to defer _explicit_ clipboard updates is difficult.
    :redir @+ | silent echo system('cat foo') | redir END
is essentially equivalent to:
    for l in readfile('foo')
        let @+ .= l
    endfor
We cannot make judgements about when to ignore a script's bad decisions.
start_batch_changes() only works around the case of clipboard=unnamed,
i.e. _implicit_ clipboard updates (`:g/foo/d`).  Not explicit
assignment.
2017-08-20 20:01:22 +02:00

42 lines
861 B
VimL

let g:test_clip = { '+': [''], '*': [''], }
let s:methods = {}
let g:cliplossy = 0
let g:cliperror = 0
" Count how many times the clipboard was invoked.
let g:clip_called_get = 0
let g:clip_called_set = 0
function! s:methods.get(reg)
let g:clip_called_get += 1
if g:cliperror
return 0
end
if g:cliplossy
" behave like pure text clipboard
return g:test_clip[a:reg][0]
else
" behave like VIMENC clipboard
return g:test_clip[a:reg]
end
endfunction
function! s:methods.set(lines, regtype, reg)
let g:clip_called_set += 1
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
function! provider#clipboard#Call(method, args)
return call(s:methods[a:method],a:args,s:methods)
endfunction