Trying to do something with job output in exit_cb
or close_cb
, but it's all buffered, how to flush it. e.g.:
function! s:exit_cb(job, status)
echom getbufline(s:bufnr, '$')
endfunction
function! s:close_cb(channel)
echom getbufline(s:bufnr, '$')
endfunction
let s:bufnr = term_start('seq 1000',
\ {'exit_cb': function("s:exit_cb"), 'close_cb':function("s:close_cb") })
None of them echo 1000
, how to flush it ?
One work around is to call :h :sleep
, but i don't think that's the right way.
update
As B Layer pointed out, result of close_cb
depends on terminal window height. e.g., if it's height is 30, it prints 971
, as 971 = 1000 - 30 + 1
.
I reread :h close_cb
, it says:
Vim will invoke callbacks that handle data before invoking close_cb, thus when this function is called no more data will be passed to the callbacks.
I guess the callback vim invoked to handle data haven't finished by the time close_cb
is called. Tried to call term_wait()
in close_cb
, but it cause hang.
update
A similar issue on github.
:h job-exit_cb
Saysdata can be buffered
, i guess the same thing happen forjob-close_cb
. I havn't straced it. I will try it later.channel
inexit_cb
, but it havn't finished updating it. See update.