patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Problem: ch_readraw() waits for NL if channel mode is NL.
Solution: Pass a "raw" flag to channel_read_block(). (Yasuhiro Matsumoto)
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 034bd39..1859afc 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -515,7 +515,7 @@
call assert_equal("AND this", ch_readraw(handle))
call ch_sendraw(handle, "split this line\n")
- call assert_equal("this linethis linethis line", ch_readraw(handle))
+ call assert_equal("this linethis linethis line", ch_read(handle))
let reply = ch_evalraw(handle, "quit\n")
call assert_equal("Goodbye!", reply)
@@ -1266,6 +1266,31 @@
endtry
endfunc
+" Use channel in NL mode but received text does not end in NL.
+func Test_read_in_close_cb_incomplete()
+ if !has('job')
+ return
+ endif
+ call ch_log('Test_read_in_close_cb_incomplete()')
+
+ let g:Ch_received = ''
+ func! CloseHandler(chan)
+ while ch_status(a:chan, {'part': 'out'}) == 'buffered'
+ let g:Ch_received .= ch_read(a:chan)
+ endwhile
+ endfunc
+ let job = job_start(s:python . " test_channel_pipe.py incomplete",
+ \ {'close_cb': 'CloseHandler'})
+ call assert_equal("run", job_status(job))
+ try
+ call WaitFor('g:Ch_received != ""')
+ call assert_equal('incomplete', g:Ch_received)
+ finally
+ call job_stop(job)
+ delfunc CloseHandler
+ endtry
+endfunc
+
func Test_out_cb_lambda()
if !has('job')
return