mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
provider/clipboard.vim: capture/display errors (#6684)
TODO: handle errors in the `get`. systemlist() should take an options dictionary like jobstart(), which may specify a stderr handler. References #6565
This commit is contained in:
parent
d8fe63199f
commit
4dee942e73
@ -137,16 +137,24 @@ function! s:clipboard.set(lines, regtype, reg) abort
|
||||
let argv = split(s:copy[a:reg], " ")
|
||||
let selection.detach = s:cache_enabled
|
||||
let selection.cwd = "/"
|
||||
call extend(selection, {
|
||||
\ 'on_stdout': function('s:set_errhandler'),
|
||||
\ 'on_stderr': function('s:set_errhandler'),
|
||||
\ })
|
||||
let jobid = jobstart(argv, selection)
|
||||
if jobid <= 0
|
||||
echohl WarningMsg
|
||||
echo "clipboard: error when invoking provider"
|
||||
echohl None
|
||||
return 0
|
||||
if jobid > 0
|
||||
call jobsend(jobid, a:lines)
|
||||
call jobclose(jobid, 'stdin')
|
||||
let selection.owner = jobid
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:set_errhandler(job_id, data, event) abort
|
||||
if a:job_id <= 0
|
||||
echohl WarningMsg
|
||||
echo 'clipboard: error when invoking provider: ' . join(a:data)
|
||||
echohl None
|
||||
endif
|
||||
call jobsend(jobid, a:lines)
|
||||
call jobclose(jobid, 'stdin')
|
||||
let selection.owner = jobid
|
||||
endfunction
|
||||
|
||||
function! provider#clipboard#Call(method, args) abort
|
||||
|
Loading…
Reference in New Issue
Block a user