Skip to content

Commit 151f656

Browse files
committed
patch 7.4.1509
Problem: Keeping both a variable for a job and the channel it refers to is a hassle. Solution: Allow passing the job where a channel is expected. (Damien)
1 parent 47cff3a commit 151f656

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/eval.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10285,14 +10285,22 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported)
1028510285
static channel_T *
1028610286
get_channel_arg(typval_T *tv)
1028710287
{
10288-
channel_T *channel;
10288+
channel_T *channel = NULL;
1028910289

10290-
if (tv->v_type != VAR_CHANNEL)
10290+
if (tv->v_type == VAR_JOB)
10291+
{
10292+
if (tv->vval.v_job != NULL)
10293+
channel = tv->vval.v_job->jv_channel;
10294+
}
10295+
else if (tv->v_type == VAR_CHANNEL)
10296+
{
10297+
channel = tv->vval.v_channel;
10298+
}
10299+
else
1029110300
{
1029210301
EMSG2(_(e_invarg2), get_tv_string(tv));
1029310302
return NULL;
1029410303
}
10295-
channel = tv->vval.v_channel;
1029610304

1029710305
if (channel == NULL || !channel_is_open(channel))
1029810306
{
@@ -15106,7 +15114,7 @@ f_job_setoptions(typval_T *argvars, typval_T *rettv UNUSED)
1510615114
* "job_start()" function
1510715115
*/
1510815116
static void
15109-
f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
15117+
f_job_start(typval_T *argvars, typval_T *rettv)
1511015118
{
1511115119
job_T *job;
1511215120
char_u *cmd = NULL;

src/testdir/test_channel.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,16 @@ func Test_raw_pipe()
463463
let job = job_start(s:python . " test_channel_pipe.py", {'mode': 'raw'})
464464
call assert_equal("run", job_status(job))
465465
try
466-
let handle = job_getchannel(job)
467-
call ch_sendraw(handle, "echo something\n")
468-
let msg = ch_readraw(handle)
466+
" For a change use the job where a channel is expected.
467+
call ch_sendraw(job, "echo something\n")
468+
let msg = ch_readraw(job)
469469
call assert_equal("something\n", substitute(msg, "\r", "", 'g'))
470470

471-
call ch_sendraw(handle, "double this\n")
472-
let msg = ch_readraw(handle)
471+
call ch_sendraw(job, "double this\n")
472+
let msg = ch_readraw(job)
473473
call assert_equal("this\nAND this\n", substitute(msg, "\r", "", 'g'))
474474

475-
let reply = ch_evalraw(handle, "quit\n", {'timeout': 100})
475+
let reply = ch_evalraw(job, "quit\n", {'timeout': 100})
476476
call assert_equal("Goodbye!\n", substitute(reply, "\r", "", 'g'))
477477
finally
478478
call job_stop(job)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1509,
746748
/**/
747749
1508,
748750
/**/

0 commit comments

Comments
 (0)