diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-08-12 19:16:06 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-08-13 08:52:17 -0300 |
commit | 6b3cd381dcd01268479dc56103498a029133644d (patch) | |
tree | 0944a99a09ca4c574d4a3945e9bcb9d4f0e8d505 /src/nvim/eval.c | |
parent | 166d8c799f367e64744cef4d9a6ddd386809ece8 (diff) | |
download | rneovim-6b3cd381dcd01268479dc56103498a029133644d.tar.gz rneovim-6b3cd381dcd01268479dc56103498a029133644d.tar.bz2 rneovim-6b3cd381dcd01268479dc56103498a029133644d.zip |
rstream: Pass read count to read events
This is necessary to keep events in the same order received from the OS.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9d838406ac..ab0c7d79bb 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21176,38 +21176,43 @@ static inline void process_job_event(TerminalJobData *data, ufunc_T *callback, on_job_event(&event_data); } -static void on_job_stdout(Stream *stream, RBuffer *buf, void *job, bool eof) +static void on_job_stdout(Stream *stream, RBuffer *buf, size_t count, + void *job, bool eof) { TerminalJobData *data = job; - on_job_output(stream, job, buf, eof, data->on_stdout, "stdout"); + on_job_output(stream, job, buf, count, eof, data->on_stdout, "stdout"); } -static void on_job_stderr(Stream *stream, RBuffer *buf, void *job, bool eof) +static void on_job_stderr(Stream *stream, RBuffer *buf, size_t count, + void *job, bool eof) { TerminalJobData *data = job; - on_job_output(stream, job, buf, eof, data->on_stderr, "stderr"); + on_job_output(stream, job, buf, count, eof, data->on_stderr, "stderr"); } static void on_job_output(Stream *stream, TerminalJobData *data, RBuffer *buf, - bool eof, ufunc_T *callback, const char *type) + size_t count, bool eof, ufunc_T *callback, const char *type) { if (eof) { return; } - RBUFFER_UNTIL_EMPTY(buf, ptr, len) { - // The order here matters, the terminal must receive the data first because - // process_job_event will modify the read buffer(convert NULs into NLs) - if (data->term) { - terminal_receive(data->term, ptr, len); - } + // stub variable, to keep reading consistent with the order of events, only + // consider the count parameter. + size_t r; + char *ptr = rbuffer_read_ptr(buf, &r); - if (callback) { - process_job_event(data, callback, type, ptr, len, 0); - } + // The order here matters, the terminal must receive the data first because + // process_job_event will modify the read buffer(convert NULs into NLs) + if (data->term) { + terminal_receive(data->term, ptr, count); + } - rbuffer_consumed(buf, len); + if (callback) { + process_job_event(data, callback, type, ptr, count, 0); } + + rbuffer_consumed(buf, count); } static void on_process_exit(Process *proc, int status, void *d) |