clipboard: avoid redundant error message on clipboard_get failure .

Fixes #2712

Helped-By: Michael Reed <m.reed@mykolab.com>
This commit is contained in:
Björn Linse 2015-06-09 22:05:52 +02:00 committed by Justin M. Keyes
parent d133502e98
commit 3fcfd52422
2 changed files with 14 additions and 4 deletions

View File

@ -22,14 +22,15 @@ function! s:try_cmd(cmd, ...)
let argv = split(a:cmd, " ")
let out = a:0 ? systemlist(argv, a:1, 1) : systemlist(argv, [''], 1)
if v:shell_error
echohl WarningMsg
echo "clipboard: error: ".(len(out) ? out[0] : '')
return ''
echohl None
return 0
endif
return out
endfunction
let s:cache_enabled = 1
if executable('pbcopy')
let s:copy['+'] = 'pbcopy'
let s:paste['+'] = 'pbpaste'
@ -47,7 +48,7 @@ elseif executable('xsel')
let s:copy['*'] = 'xsel --nodetach -i -p'
let s:paste['*'] = 'xsel -o -p'
else
echom 'clipboard: No shell command for communicating with the clipboard found.'
echom 'clipboard: No clipboard tool available. See :help nvim-clipboard'
finish
endif

View File

@ -5291,6 +5291,9 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet)
static bool get_clipboard(int name, yankreg_T **target, bool quiet)
{
// show message on error
bool errmsg = true;
yankreg_T *reg = adjust_clipboard_name(&name, quiet);
if (reg == NULL) {
return false;
@ -5304,6 +5307,10 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
typval_T result = eval_call_provider("clipboard", "get", args);
if (result.v_type != VAR_LIST) {
if (result.v_type == VAR_NUMBER && result.vval.v_number == 0) {
// failure has already been indicated by provider
errmsg = false;
}
goto err;
}
@ -5389,7 +5396,9 @@ err:
}
reg->y_array = NULL;
reg->y_size = 0;
if (errmsg) {
EMSG("clipboard: provider returned invalid data");
}
*target = reg;
return false;
}