File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3450,15 +3450,19 @@ term_after_channel_closed(term_T *term)
34503450 if (term -> tl_finish == TL_FINISH_OPEN
34513451 && term -> tl_buffer -> b_nwindows == 0 )
34523452 {
3453- char buf [50 ];
3454-
3455- // TODO: use term_opencmd
3456- ch_log (NULL , "terminal job finished, opening window" );
3457- vim_snprintf (buf , sizeof (buf ),
3458- term -> tl_opencmd == NULL
3459- ? "botright sbuf %d"
3460- : (char * )term -> tl_opencmd , fnum );
3461- do_cmdline_cmd ((char_u * )buf );
3453+ char * cmd = term -> tl_opencmd == NULL
3454+ ? "botright sbuf %d"
3455+ : (char * )term -> tl_opencmd ;
3456+ size_t len = strlen (cmd ) + 50 ;
3457+ char * buf = alloc (len );
3458+
3459+ if (buf != NULL )
3460+ {
3461+ ch_log (NULL , "terminal job finished, opening window" );
3462+ vim_snprintf (buf , len , cmd , fnum );
3463+ do_cmdline_cmd ((char_u * )buf );
3464+ vim_free (buf );
3465+ }
34623466 }
34633467 else
34643468 ch_log (NULL , "terminal job finished" );
Original file line number Diff line number Diff line change @@ -567,10 +567,12 @@ func Test_terminal_finish_open_close()
567567 call assert_fails (" call term_start(cmd, {'term_opencmd': 'split %d and %s'})" , ' E475:' )
568568 call assert_fails (" call term_start(cmd, {'term_opencmd': 'split % and %d'})" , ' E475:' )
569569
570- call term_start (cmd, {' term_finish' : ' open' , ' term_opencmd' : ' 4split | buffer %d' })
570+ call term_start (cmd, {' term_finish' : ' open' , ' term_opencmd' : ' 4split | buffer %d | let g:result = "opened the buffer in a window" ' })
571571 close !
572572 call WaitForAssert ({- > assert_equal (2 , winnr (' $' ))}, waittime)
573573 call assert_equal (4 , winheight (0 ))
574+ call assert_equal (' opened the buffer in a window' , g: result )
575+ unlet g: result
574576 bwipe
575577endfunc
576578
Original file line number Diff line number Diff line change @@ -750,6 +750,8 @@ static char *(features[]) =
750750
751751static int included_patches [] =
752752{ /* Add new patch number below this line */
753+ /**/
754+ 1979 ,
753755/**/
754756 1978 ,
755757/**/
You can’t perform that action at this time.
0 commit comments