patch 8.0.0105
Problem: When using ch_read() with zero timeout, can't tell the difference
between reading an empty line and nothing available.
Solution: Add ch_canread().
This commit is contained in:
@ -418,7 +418,11 @@ This uses the channel timeout. To read without a timeout, just get any
|
||||
message that is available: >
|
||||
let output = ch_read(channel, {'timeout': 0})
|
||||
When no message was available then the result is v:none for a JSON or JS mode
|
||||
channels, an empty string for a RAW or NL channel.
|
||||
channels, an empty string for a RAW or NL channel. You can use |ch_canread()|
|
||||
to check if there is something to read.
|
||||
|
||||
Note that when there is no callback message are dropped. To avoid that add a
|
||||
close callback to the channel.
|
||||
|
||||
To read all output from a RAW channel that is available: >
|
||||
let output = ch_readraw(channel)
|
||||
@ -470,6 +474,11 @@ This depends on the system (on Unix this happens because closing the write end
|
||||
of a pipe causes the read end to get EOF). To avoid this make the job sleep
|
||||
for a short while before it exits.
|
||||
|
||||
Note that if the job exits before you read the output, the output may be lost.
|
||||
This depends on the system (on Unix this happens because closing the write end
|
||||
of a pipe causes the read end to get EOF). To avoid this make the job sleep
|
||||
for a short while before it exits.
|
||||
|
||||
The handler defined for "out_cb" will not receive stderr. If you want to
|
||||
handle that separately, add an "err_cb" handler: >
|
||||
let job = job_start(command, {"out_cb": "MyHandler",
|
||||
|
||||
Reference in New Issue
Block a user