Skip to content

Commit 5fdb44c

Browse files
64-bitmanchrisbra
authored andcommitted
patch 9.2.0723: term_start() does not support "noclose"
Problem: term_start() does not support "noclose" Solution: Add support for "noclose" for the "term_finish" option of term_start() (Foxe Chen) closes: #20620 Signed-off-by: Foxe Chen <chen.foxe@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 9ed2c95 commit 5fdb44c

6 files changed

Lines changed: 27 additions & 4 deletions

File tree

runtime/doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11012,6 +11012,7 @@ tempfile change.txt /*tempfile*
1101211012
template autocmd.txt /*template*
1101311013
tempname() builtin.txt /*tempname()*
1101411014
term++close terminal.txt /*term++close*
11015+
term++noclose terminal.txt /*term++noclose*
1101511016
term++open terminal.txt /*term++open*
1101611017
term++shell terminal.txt /*term++shell*
1101711018
term-dependent-settings term.txt /*term-dependent-settings*

runtime/doc/terminal.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*terminal.txt* For Vim version 9.2. Last change: 2026 Apr 06
1+
*terminal.txt* For Vim version 9.2. Last change: 2026 Jun 24
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -232,7 +232,7 @@ Command syntax ~
232232
keys in the terminal window. For MS-Windows see the
233233
++eof argument below.
234234

235-
*term++close* *term++open*
235+
*term++close* *term++noclose* *term++open*
236236
Supported [options] are:
237237
++close The terminal window will close
238238
automatically when the job terminates.
@@ -1001,9 +1001,11 @@ term_start({cmd} [, {options}]) *term_start()*
10011001
terminal window, see |term_setkill()|
10021002
"term_finish" What to do when the job is finished:
10031003
"close": close any windows
1004+
"noclose": window will not be opened
10041005
"open": open window if needed
10051006
Note that "open" can be interruptive.
1006-
See |term++close| and |term++open|.
1007+
See |term++close|, |term++noclose| and
1008+
|term++open|.
10071009
"term_opencmd" command to use for opening the window
10081010
when "open" is used for "term_finish";
10091011
must have "%d" where the buffer number

runtime/doc/version9.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52657,6 +52657,7 @@ Other ~
5265752657
not drop leading spaces |stl-%0{|.
5265852658
- Generated Session and View files are written in Vim9 script, see |:mksession|,
5265952659
|:mkview| and |:mkvimrc|
52660+
- The "term_finish" option of term_start() supports a "noclose" value.
5266052661

5266152662
Platform specific ~
5266252663
-----------------

src/job.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
386386
if (!(supported2 & JO2_TERM_FINISH))
387387
break;
388388
val = tv_get_string(item);
389-
if (STRCMP(val, "open") != 0 && STRCMP(val, "close") != 0)
389+
if (STRCMP(val, "open") != 0 && STRCMP(val, "close") != 0
390+
&& STRCMP(val, "noclose") != 0)
390391
{
391392
semsg(_(e_invalid_value_for_argument_str_str),
392393
"term_finish", val);

src/testdir/test_terminal.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,22 @@ func Test_terminal_finish_open_close()
774774
call assert_equal('opened the buffer in a window', g:result)
775775
unlet g:result
776776
bwipe
777+
778+
" Test "noclose" for term_start()
779+
let cmd = Get_cat_123_cmd()
780+
781+
let buf = term_start(cmd, {
782+
\ 'term_finish': 'noclose',
783+
\ 'hidden': v:true
784+
\ })
785+
786+
call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
787+
788+
let info = getbufinfo(buf)[0]
789+
call assert_equal(1, info.hidden)
790+
call assert_equal(1, info.listed)
791+
call assert_equal(1, info.loaded)
792+
call WaitForAssert({-> assert_equal(['123'], getbufline(buf, 1, 1))})
777793
endfunc
778794

779795
func Test_terminal_cwd()

src/version.c

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

760760
static int included_patches[] =
761761
{ /* Add new patch number below this line */
762+
/**/
763+
723,
762764
/**/
763765
722,
764766
/**/

0 commit comments

Comments
 (0)