Mercurial > vim
changeset 15217:49bc670c3ee9 v8.1.0618
patch 8.1.0618: term_getjob() does not return v:null as documented
commit https://github.com/vim/vim/commit/528ccfbaa1cc805f430a750c551e5a9fd7eb54fe
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Dec 21 20:55:22 2018 +0100
patch 8.1.0618: term_getjob() does not return v:null as documented
Problem: term_getjob() does not return v:null as documented.
Solution: Do return v:null. (Damien) Add a test.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 21 Dec 2018 21:00:06 +0100 |
parents | 0fd814a309db |
children | d8a6097d1f52 |
files | src/terminal.c src/testdir/test_terminal.vim src/version.c |
diffstat | 3 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/terminal.c +++ b/src/terminal.c @@ -4794,11 +4794,14 @@ f_term_getjob(typval_T *argvars, typval_ { buf_T *buf = term_get_buf(argvars, "term_getjob()"); + if (buf == NULL) + { + rettv->v_type = VAR_SPECIAL; + rettv->vval.v_number = VVAL_NULL; + return; + } + rettv->v_type = VAR_JOB; - rettv->vval.v_job = NULL; - if (buf == NULL) - return; - rettv->vval.v_job = buf->b_term->tl_job; if (rettv->vval.v_job != NULL) ++rettv->vval.v_job->jv_refcount;
--- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -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