async.vim icon indicating copy to clipboard operation
async.vim copied to clipboard

Bug in the Readme example

Open Lyot opened this issue 2 years ago • 1 comments

Hi, I just tried out the example from the Readme and it crashes in the handler on_exit due to a:data being of type number and not list.

function! s:handler(job_id, data, event_type)
    echo a:job_id . ' ' . a:event_type
    " Error happens here as join() expects a list
    echo join(a:data, "\n")
endfunction

Am I correct that this is simply a bug because on_exit returns the status code of the command?

I am running Vim version 8.2 1-4745.

Lyot avatar Apr 24 '22 23:04 Lyot

Seems like a bug in readme sample code and not in async.vim. Thanks for catching!

You can check the a:event_type to be stdout or stderr or create a different handler for on_exit.

Feel free to send a PR to update the sample.

prabirshrestha avatar Apr 30 '22 04:04 prabirshrestha