3838 * in tl_scrollback are no longer used.
3939 *
4040 * TODO:
41- * - ":term NONE" does not work in MS-Windows.
41+ * - ":term NONE" does not work on MS-Windows.
42+ * https://github.com/vim/vim/pull/2056
43+ * - Redirecting output does not work on MS-Windows.
4244 * - implement term_setsize()
4345 * - add test for giving error for invalid 'termsize' value.
4446 * - support minimal size when 'termsize' is "rows*cols".
5658 * - In the GUI use a terminal emulator for :!cmd.
5759 * - Copy text in the vterm to the Vim buffer once in a while, so that
5860 * completion works.
61+ * - add an optional limit for the scrollback size. When reaching it remove
62+ * 10% at the start.
5963 */
6064
6165#include "vim.h"
@@ -366,10 +370,10 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
366370 }
367371 else if (argvar -> v_type != VAR_LIST
368372 || argvar -> vval .v_list == NULL
369- || argvar -> vval .v_list -> lv_len < 1 )
373+ || argvar -> vval .v_list -> lv_len < 1
374+ || (cmd = get_tv_string_chk (
375+ & argvar -> vval .v_list -> lv_first -> li_tv )) == NULL )
370376 cmd = (char_u * )"" ;
371- else
372- cmd = get_tv_string_chk (& argvar -> vval .v_list -> lv_first -> li_tv );
373377
374378 len = STRLEN (cmd ) + 10 ;
375379 p = alloc ((int )len );
@@ -458,7 +462,7 @@ term_start(typval_T *argvar, jobopt_T *opt, int forceit)
458462 void
459463ex_terminal (exarg_T * eap )
460464{
461- typval_T argvar ;
465+ typval_T argvar [ 2 ] ;
462466 jobopt_T opt ;
463467 char_u * cmd ;
464468 char_u * tofree = NULL ;
@@ -521,8 +525,8 @@ ex_terminal(exarg_T *eap)
521525 }
522526 cmd = skipwhite (p );
523527 }
524- if (cmd == NULL || * cmd == NUL )
525- /* Make a copy, an autocommand may set 'shell' . */
528+ if (* cmd == NUL )
529+ /* Make a copy of 'shell' , an autocommand may change the option . */
526530 tofree = cmd = vim_strsave (p_sh );
527531
528532 if (eap -> addr_count > 0 )
@@ -535,9 +539,10 @@ ex_terminal(exarg_T *eap)
535539 opt .jo_in_bot = eap -> line2 ;
536540 }
537541
538- argvar .v_type = VAR_STRING ;
539- argvar .vval .v_string = cmd ;
540- term_start (& argvar , & opt , eap -> forceit );
542+ argvar [0 ].v_type = VAR_STRING ;
543+ argvar [0 ].vval .v_string = cmd ;
544+ argvar [1 ].v_type = VAR_UNKNOWN ;
545+ term_start (argvar , & opt , eap -> forceit );
541546 vim_free (tofree );
542547}
543548
@@ -2887,7 +2892,8 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
28872892 && STRCMP (job_status (buf -> b_term -> tl_job ), "dead" ) == 0 )
28882893 {
28892894 /* The job is dead, keep reading channel I/O until the channel is
2890- * closed. */
2895+ * closed. buf->b_term may become NULL if the terminal was closed while
2896+ * waiting. */
28912897 ch_log (NULL , "term_wait(): waiting for channel to close" );
28922898 while (buf -> b_term != NULL && !buf -> b_term -> tl_channel_closed )
28932899 {
0 commit comments