patch 7.4.2298
Problem: It is not possible to close the "in" part of a channel.
Solution: Add ch_close_in().
diff --git a/src/channel.c b/src/channel.c
index dbed659..bbe98be 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -2736,6 +2736,15 @@
}
/*
+ * Close the "in" part channel "channel".
+ */
+ void
+channel_close_in(channel_T *channel)
+{
+ may_close_part(&channel->CH_IN_FD);
+}
+
+/*
* Clear the read buffer on "channel"/"part".
*/
static void
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 578f0f5..9d94694 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -77,6 +77,7 @@
#endif
#ifdef FEAT_JOB_CHANNEL
static void f_ch_close(typval_T *argvars, typval_T *rettv);
+static void f_ch_close_in(typval_T *argvars, typval_T *rettv);
static void f_ch_evalexpr(typval_T *argvars, typval_T *rettv);
static void f_ch_evalraw(typval_T *argvars, typval_T *rettv);
static void f_ch_getbufnr(typval_T *argvars, typval_T *rettv);
@@ -499,6 +500,7 @@
#endif
#ifdef FEAT_JOB_CHANNEL
{"ch_close", 1, 1, f_ch_close},
+ {"ch_close_in", 1, 1, f_ch_close_in},
{"ch_evalexpr", 2, 3, f_ch_evalexpr},
{"ch_evalraw", 2, 3, f_ch_evalraw},
{"ch_getbufnr", 2, 2, f_ch_getbufnr},
@@ -1792,6 +1794,18 @@
}
/*
+ * "ch_close()" function
+ */
+ static void
+f_ch_close_in(typval_T *argvars, typval_T *rettv UNUSED)
+{
+ channel_T *channel = get_channel_arg(&argvars[0], TRUE, FALSE, 0);
+
+ if (channel != NULL)
+ channel_close_in(channel);
+}
+
+/*
* "ch_getbufnr()" function
*/
static void
diff --git a/src/proto/channel.pro b/src/proto/channel.pro
index 1acae9a..869989c 100644
--- a/src/proto/channel.pro
+++ b/src/proto/channel.pro
@@ -27,6 +27,7 @@
char *channel_status(channel_T *channel);
void channel_info(channel_T *channel, dict_T *dict);
void channel_close(channel_T *channel, int invoke_close_cb);
+void channel_close_in(channel_T *channel);
void channel_clear(channel_T *channel);
void channel_free_all(void);
char_u *channel_read_block(channel_T *channel, int part, int timeout);
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 6bea0e8..0121deb 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -792,22 +792,32 @@
call Run_test_pipe_from_buffer(0)
endfunc
-func Run_pipe_through_sort(all)
+func Run_pipe_through_sort(all, use_buffer)
if !executable('sort') || !has('job')
return
endif
- split sortin
- call setline(1, ['ccc', 'aaa', 'ddd', 'bbb', 'eee'])
- let options = {'in_io': 'buffer', 'in_name': 'sortin',
- \ 'out_io': 'buffer', 'out_name': 'sortout'}
+ let options = {'out_io': 'buffer', 'out_name': 'sortout'}
+ if a:use_buffer
+ split sortin
+ call setline(1, ['ccc', 'aaa', 'ddd', 'bbb', 'eee'])
+ let options.in_io = 'buffer'
+ let options.in_name = 'sortin'
+ endif
if !a:all
let options.in_top = 2
let options.in_bot = 4
endif
let g:job = job_start('sort', options)
call assert_equal("run", job_status(g:job))
+
+ if !a:use_buffer
+ call ch_sendraw(g:job, "ccc\naaa\nddd\nbbb\neee\n")
+ call ch_close_in(g:job)
+ endif
+
call WaitFor('job_status(g:job) == "dead"')
call assert_equal("dead", job_status(g:job))
+
sp sortout
call assert_equal('Reading from channel output...', getline(1))
if a:all
@@ -818,18 +828,25 @@
call job_stop(g:job)
unlet g:job
- bwipe! sortin
+ if a:use_buffer
+ bwipe! sortin
+ endif
bwipe! sortout
endfunc
func Test_pipe_through_sort_all()
call ch_log('Test_pipe_through_sort_all()')
- call Run_pipe_through_sort(1)
+ call Run_pipe_through_sort(1, 1)
endfunc
func Test_pipe_through_sort_some()
call ch_log('Test_pipe_through_sort_some()')
- call Run_pipe_through_sort(0)
+ call Run_pipe_through_sort(0, 1)
+endfunc
+
+func Test_pipe_through_sort_feed()
+ call ch_log('Test_pipe_through_sort_feed()')
+ call Run_pipe_through_sort(1, 0)
endfunc
func Test_pipe_to_nameless_buffer()
diff --git a/src/version.c b/src/version.c
index 3162f33..87e401b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2298,
+/**/
2297,
/**/
2296,