aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Russell <arussell123@gmail.com>2017-07-15 14:51:51 -0400
committerJustin M. Keyes <justinkz@gmail.com>2017-07-15 20:51:51 +0200
commit4dee942e732d41ad62b732c0a39719d9405bc928 (patch)
tree1ec6b215a3b8112e1a2c0cac51a17a08bc67b2a6
parentd8fe63199f10c944312e802010bec13b5950120a (diff)
downloadrneovim-4dee942e732d41ad62b732c0a39719d9405bc928.tar.gz
rneovim-4dee942e732d41ad62b732c0a39719d9405bc928.tar.bz2
rneovim-4dee942e732d41ad62b732c0a39719d9405bc928.zip
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
-rw-r--r--runtime/autoload/provider/clipboard.vim20
1 files changed, 14 insertions, 6 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index a67681d28e..47f4271091 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -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
+ 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"
+ echo 'clipboard: error when invoking provider: ' . join(a:data)
echohl None
- return 0
endif
- call jobsend(jobid, a:lines)
- call jobclose(jobid, 'stdin')
- let selection.owner = jobid
endfunction
function! provider#clipboard#Call(method, args) abort