robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #10161 from equalsraf/tb-clipboard-reload96be8a2c4d

master
897 B42 linesraw
1let g:loaded_clipboard_provider = 2
2
3let g:test_clip = { '+': [''], '*': [''], }
4
5let s:methods = {}
6
7let g:cliplossy = 0
8let g:cliperror = 0
9
10" Count how many times the clipboard was invoked.
11let g:clip_called_get = 0
12let g:clip_called_set = 0
13
14function! s:methods.get(reg)
15  let g:clip_called_get += 1
16
17  if g:cliperror
18    return 0
19  end
20  if g:cliplossy
21    " behave like pure text clipboard
22    return g:test_clip[a:reg][0]
23  else
24    " behave like VIMENC clipboard
25    return g:test_clip[a:reg]
26  end
27endfunction
28
29function! s:methods.set(lines, regtype, reg)
30  let g:clip_called_set += 1
31
32  if a:reg == '"'
33    call s:methods.set(a:lines,a:regtype,'+')
34    call s:methods.set(a:lines,a:regtype,'*')
35    return 0
36  end
37  let g:test_clip[a:reg] = [a:lines, a:regtype]
38endfunction
39
40function! provider#clipboard#Call(method, args)
41  return call(s:methods[a:method],a:args,s:methods)
42endfunction