mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.1.0481: Vim9: term_getjob() throws an exception on error
Problem: Vim9: term_getjob() throws an exception on error Solution: Return null_job instead, when there is no job (Ernie Rael) closes: #14984 Signed-off-by: Ernie Rael <errael@raelity.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
1c29602662
commit
a78eb25db3
@@ -1,4 +1,4 @@
|
|||||||
*terminal.txt* For Vim version 9.1. Last change: 2024 Jun 08
|
*terminal.txt* For Vim version 9.1. Last change: 2024 Jun 13
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@@ -647,7 +647,8 @@ term_getcursor({buf}) *term_getcursor()*
|
|||||||
term_getjob({buf}) *term_getjob()*
|
term_getjob({buf}) *term_getjob()*
|
||||||
Get the Job associated with terminal window {buf}.
|
Get the Job associated with terminal window {buf}.
|
||||||
{buf} is used as with |term_getsize()|.
|
{buf} is used as with |term_getsize()|.
|
||||||
Returns |v:null| when there is no job.
|
Returns |v:null| when there is no job. In Vim9 script, return
|
||||||
|
null_job when there is no job.
|
||||||
|
|
||||||
Can also be used as a |method|: >
|
Can also be used as a |method|: >
|
||||||
GetBufnr()->term_getjob()
|
GetBufnr()->term_getjob()
|
||||||
|
@@ -6170,9 +6170,17 @@ f_term_getjob(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
buf = term_get_buf(argvars, "term_getjob()");
|
buf = term_get_buf(argvars, "term_getjob()");
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
|
{
|
||||||
|
if (in_vim9script())
|
||||||
|
{
|
||||||
|
rettv->v_type = VAR_JOB;
|
||||||
|
rettv->vval.v_job = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rettv->v_type = VAR_SPECIAL;
|
rettv->v_type = VAR_SPECIAL;
|
||||||
rettv->vval.v_number = VVAL_NULL;
|
rettv->vval.v_number = VVAL_NULL;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4557,6 +4557,7 @@ enddef
|
|||||||
def Test_term_getjob()
|
def Test_term_getjob()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
v9.CheckSourceDefAndScriptFailure(['term_getjob(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
|
v9.CheckSourceDefAndScriptFailure(['term_getjob(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
|
||||||
|
v9.CheckSourceDefAndScriptSuccess(['assert_true(term_getjob(0) == null_job)'])
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_term_getline()
|
def Test_term_getline()
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
481,
|
||||||
/**/
|
/**/
|
||||||
480,
|
480,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user