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>
diff --git a/src/terminal.c b/src/terminal.c
index 07b69c6..648fc78 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -6171,8 +6171,16 @@
buf = term_get_buf(argvars, "term_getjob()");
if (buf == NULL)
{
- rettv->v_type = VAR_SPECIAL;
- rettv->vval.v_number = VVAL_NULL;
+ if (in_vim9script())
+ {
+ rettv->v_type = VAR_JOB;
+ rettv->vval.v_job = NULL;
+ }
+ else
+ {
+ rettv->v_type = VAR_SPECIAL;
+ rettv->vval.v_number = VVAL_NULL;
+ }
return;
}