Skip to content

Commit

Permalink
patch 8.1.0618: term_getjob() does not return v:null as documented
Browse files Browse the repository at this point in the history
Problem:    term_getjob() does not return v:null as documented.
Solution:   Do return v:null. (Damien)  Add a test.
  • Loading branch information
brammool committed Dec 21, 2018
1 parent 1916673 commit 528ccfb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/terminal.c
Expand Up @@ -4794,11 +4794,14 @@ f_term_getjob(typval_T *argvars, typval_T *rettv)
{
buf_T *buf = term_get_buf(argvars, "term_getjob()");

rettv->v_type = VAR_JOB;
rettv->vval.v_job = NULL;
if (buf == NULL)
{
rettv->v_type = VAR_SPECIAL;
rettv->vval.v_number = VVAL_NULL;
return;
}

rettv->v_type = VAR_JOB;
rettv->vval.v_job = buf->b_term->tl_job;
if (rettv->vval.v_job != NULL)
++rettv->vval.v_job->jv_refcount;
Expand Down
5 changes: 5 additions & 0 deletions src/testdir/test_terminal.vim
Expand Up @@ -1714,3 +1714,8 @@ func Test_stop_in_terminal()
call Stop_shell_in_terminal(bufnr)
exe bufnr . 'bwipe'
endfunc

func Test_terminal_no_job()
let term = term_start('false', {'term_finish': 'close'})
call WaitForAssert({-> assert_equal(v:null, term_getjob(term)) })
endfunc
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -799,6 +799,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
618,
/**/
617,
/**/
Expand Down

0 comments on commit 528ccfb

Please sign in to comment.