prabirshrestha / async.vim

normalize async job control api for vim and neovim
MIT License
278 stars 19 forks source link

Bug in the Readme example #50

Open Lyot opened 2 years ago

Lyot commented 2 years ago

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.

prabirshrestha commented 2 years ago

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.