summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomáš Janoušek <tomi@nomi.cz>2022-07-26 09:56:12 +0100
committerGitHub <noreply@github.com>2022-07-26 17:56:12 +0900
commite10fcf22dcc0441da3c984e26ae2e467b0ae554f (patch)
tree5df83f3c911f32eeb7fbe57fa59bc4fb72cfd7b5
parent854d6063331c686ded959ecb17830fb8c34f2db3 (diff)
downloadale-e10fcf22dcc0441da3c984e26ae2e467b0ae554f.zip
Prevent buffering of job output and excessive polling (#4259)
When 'close_cb' is set for job_start(), but out_cb or err_cb isn't, vim buffers data instead of dropping it (in case someone wanted to read and process it in close_cb), and additionally polls for new data every 10 milliseconds, causing excessive wakeups and CPU usage. Since we don't read the data anywhere outside of out_cb/err_cb, any LSP that prints an error to stderr triggers this and vim keeps spinning until :ALEStopAllLSPs. Fix this by always setting both callbacks, thus dropping any data we're not interested in. See https://github.com/vim/vim/issues/10758 for an upstream report of the excessive polling. It's possible this is intentional, I dunno. Fixes: b42153eb1786 ("Fix #4098 - Clear LSP data when servers crash")
-rw-r--r--autoload/ale/job.vim6
1 files changed, 6 insertions, 0 deletions
diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim
index b4a7a2e8..0fc43a8c 100644
--- a/autoload/ale/job.vim
+++ b/autoload/ale/job.vim
@@ -250,10 +250,16 @@ function! ale#job#Start(command, options) abort
if has_key(a:options, 'out_cb')
let l:job_options.out_cb = function('s:VimOutputCallback')
+ else
+ " prevent buffering of output and excessive polling in case close_cb is set
+ let l:job_options.out_cb = {->0}
endif
if has_key(a:options, 'err_cb')
let l:job_options.err_cb = function('s:VimErrorCallback')
+ else
+ " prevent buffering of output and excessive polling in case close_cb is set
+ let l:job_options.err_cb = {->0}
endif
if has_key(a:options, 'exit_cb')