Hi.

There are 2 problems about job-channel callback.


1) callback isn't invoked when last line doesn't terminate by NL.

[repro steps]

test.vim

---
function! Callback(ch, msg)
  echom a:msg
  let g:linecount += 1
endfunction

let g:linecount = 0
call job_start(['python', '-c', 'import sys;sys.stdout.write("1\n2\n3")'], 
{'callback': 'Callback'})
---

vim -Nu NONE -S test.vim

expected: g:linecount == 3 and ':messages shows;

----
1
2
3
----

actual: g:linecount == 2 and  ':messages' shows;

----
1
2
----

[patch]

- Flush last line when no ending NL

https://gist.github.com/ichizok/a60b96fc5c913b260c34a7e9e1a02de8


2) callback isn't invoked when job immediately terminates.

[repro steps]

test.vim

----
function! Callback(ch, msg)
  echom a:msg
  let g:linecount += 1
endfunction

let g:linecount = 0
call job_start(['python', '-c', 'import 
os,sys;os.close(1);sys.stderr.write("1\n")'], {'callback': 'Callback'})
----

vim -Nu NONE -S test.vim

expected: ':messages' shows "1" and g:linecount == 1

actual: ':messages' shows nothing and g:linecount == 0

[cause]

When one of the fds associated with job-channel reachs EOF,
job-channel are closed even if other fds has readable data.

[patch]

- Don't close job-channel until all readable fds are closed

https://gist.github.com/ichizok/6e0c00daf387b32bebcc2972f0cca137


Thank you.
- Ozaki Kiichi

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui