aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-09-18 18:21:44 +0200
committerGitHub <noreply@github.com>2019-09-18 18:21:44 +0200
commitd4785421106c9ac81adc9ddd5778446d80dbc4ba (patch)
tree73bfa74fb8735b6230c7c59bbf28bde2e9e28043
parent618045685bf02d770e6011ca0eef72eba3b99ee2 (diff)
downloadrneovim-d4785421106c9ac81adc9ddd5778446d80dbc4ba.tar.gz
rneovim-d4785421106c9ac81adc9ddd5778446d80dbc4ba.tar.bz2
rneovim-d4785421106c9ac81adc9ddd5778446d80dbc4ba.zip
health#provider: fix duplicated output/stderr (#11048)
Ref: https://github.com/neovim/neovim/pull/11047#issuecomment-532268826
-rw-r--r--runtime/autoload/health/provider.vim18
1 files changed, 13 insertions, 5 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 87d82150b6..f1238edbde 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -38,9 +38,10 @@ endfunction
" Handler for s:system() function.
function! s:system_handler(jobid, data, event) dict abort
if a:event ==# 'stderr'
- let self.stderr .= join(a:data, '')
- if !self.ignore_stderr
+ if self.add_stderr_to_output
let self.output .= join(a:data, '')
+ else
+ let self.stderr .= join(a:data, '')
endif
elseif a:event ==# 'stdout'
let self.output .= join(a:data, '')
@@ -64,7 +65,7 @@ function! s:system(cmd, ...) abort
let stdin = a:0 ? a:1 : ''
let ignore_error = a:0 > 2 ? a:3 : 0
let opts = {
- \ 'ignore_stderr': a:0 > 1 ? a:2 : 0,
+ \ 'add_stderr_to_output': a:0 > 1 ? a:2 : 0,
\ 'output': '',
\ 'stderr': '',
\ 'on_stdout': function('s:system_handler'),
@@ -89,8 +90,15 @@ function! s:system(cmd, ...) abort
call health#report_error(printf('Command timed out: %s', s:shellify(a:cmd)))
call jobstop(jobid)
elseif s:shell_error != 0 && !ignore_error
- call health#report_error(printf("Command error (job=%d, exit code %d): `%s` (in %s)\nOutput: %s\nStderr: %s",
- \ jobid, s:shell_error, s:shellify(a:cmd), string(getcwd()), opts.output, opts.stderr))
+ let emsg = printf("Command error (job=%d, exit code %d): `%s` (in %s)",
+ \ jobid, s:shell_error, s:shellify(a:cmd), string(getcwd()))
+ if !empty(opts.output)
+ let emsg .= "\noutput: " . opts.output
+ end
+ if !empty(opts.stderr)
+ let emsg .= "\nstderr: " . opts.stderr
+ end
+ call health#report_error(emsg)
endif
return opts.output