summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/channel.c26
-rw-r--r--src/testdir/test_channel.vim47
-rw-r--r--src/version.c2
3 files changed, 71 insertions, 4 deletions
diff --git a/src/channel.c b/src/channel.c
index dec0c79be..3856dabbc 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -871,7 +871,7 @@ channel_set_job(channel_T *channel, job_T *job, jobopt_T *options)
* Find a buffer matching "name" or create a new one.
*/
static buf_T *
-find_buffer(char_u *name)
+find_buffer(char_u *name, int err)
{
buf_T *buf = NULL;
buf_T *save_curbuf = curbuf;
@@ -890,7 +890,8 @@ find_buffer(char_u *name)
curbuf = buf;
if (curbuf->b_ml.ml_mfp == NULL)
ml_open(curbuf);
- ml_replace(1, (char_u *)"Reading from channel output...", TRUE);
+ ml_replace(1, (char_u *)(err ? "Reading from channel error..."
+ : "Reading from channel output..."), TRUE);
changed_bytes(1, 0);
curbuf = save_curbuf;
}
@@ -968,10 +969,27 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
if (!(opt->jo_set & JO_OUT_MODE))
channel->ch_part[PART_OUT].ch_mode = MODE_NL;
channel->ch_part[PART_OUT].ch_buffer =
- find_buffer(opt->jo_io_name[PART_OUT]);
- ch_logs(channel, "writing to buffer '%s'",
+ find_buffer(opt->jo_io_name[PART_OUT], FALSE);
+ ch_logs(channel, "writing out to buffer '%s'",
(char *)channel->ch_part[PART_OUT].ch_buffer->b_ffname);
}
+
+ if ((opt->jo_set & JO_ERR_IO) && (opt->jo_io[PART_ERR] == JIO_BUFFER
+ || (opt->jo_io[PART_ERR] == JIO_OUT && (opt->jo_set & JO_OUT_IO)
+ && opt->jo_io[PART_OUT] == JIO_BUFFER)))
+ {
+ /* writing err to a buffer. Default mode is NL. */
+ if (!(opt->jo_set & JO_ERR_MODE))
+ channel->ch_part[PART_ERR].ch_mode = MODE_NL;
+ if (opt->jo_io[PART_ERR] == JIO_OUT)
+ channel->ch_part[PART_ERR].ch_buffer =
+ channel->ch_part[PART_OUT].ch_buffer;
+ else
+ channel->ch_part[PART_ERR].ch_buffer =
+ find_buffer(opt->jo_io_name[PART_ERR], TRUE);
+ ch_logs(channel, "writing err to buffer '%s'",
+ (char *)channel->ch_part[PART_ERR].ch_buffer->b_ffname);
+ }
}
/*
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 061b30c25..7b531c8f0 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -633,6 +633,53 @@ func Test_pipe_to_buffer()
endtry
endfunc
+func Test_pipe_err_to_buffer()
+ if !has('job')
+ return
+ endif
+ call ch_log('Test_pipe_err_to_buffer()')
+ let job = job_start(s:python . " test_channel_pipe.py",
+ \ {'err-io': 'buffer', 'err-name': 'pipe-err'})
+ call assert_equal("run", job_status(job))
+ try
+ let handle = job_getchannel(job)
+ call ch_sendraw(handle, "echoerr line one\n")
+ call ch_sendraw(handle, "echoerr line two\n")
+ call ch_sendraw(handle, "doubleerr this\n")
+ call ch_sendraw(handle, "quit\n")
+ sp pipe-err
+ call s:waitFor('line("$") >= 5')
+ call assert_equal(['Reading from channel error...', 'line one', 'line two', 'this', 'AND this'], getline(1, '$'))
+ bwipe!
+ finally
+ call job_stop(job)
+ endtry
+endfunc
+
+func Test_pipe_both_to_buffer()
+ if !has('job')
+ return
+ endif
+ call ch_log('Test_pipe_both_to_buffer()')
+ let job = job_start(s:python . " test_channel_pipe.py",
+ \ {'out-io': 'buffer', 'out-name': 'pipe-err', 'err-io': 'out'})
+ call assert_equal("run", job_status(job))
+ try
+ let handle = job_getchannel(job)
+ call ch_sendraw(handle, "echo line one\n")
+ call ch_sendraw(handle, "echoerr line two\n")
+ call ch_sendraw(handle, "double this\n")
+ call ch_sendraw(handle, "doubleerr that\n")
+ call ch_sendraw(handle, "quit\n")
+ sp pipe-err
+ call s:waitFor('line("$") >= 7')
+ call assert_equal(['Reading from channel output...', 'line one', 'line two', 'this', 'AND this', 'that', 'AND that', 'Goodbye!'], getline(1, '$'))
+ bwipe!
+ finally
+ call job_stop(job)
+ endtry
+endfunc
+
func Test_pipe_from_buffer()
if !has('job')
return
diff --git a/src/version.c b/src/version.c
index 5d7a968da..0c0e5bd0b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -744,6 +744,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1522,
+/**/
1521,
/**/
1520,