File tree Expand file tree Collapse file tree 4 files changed +50
-10
lines changed Expand file tree Collapse file tree 4 files changed +50
-10
lines changed Original file line number Diff line number Diff line change @@ -995,6 +995,19 @@ is_not_a_term()
995995 return params .not_a_term ;
996996}
997997
998+ /*
999+ * Return TRUE when the --not-a-term argument was found or the GUI is in use.
1000+ */
1001+ static int
1002+ is_not_a_term_or_gui ()
1003+ {
1004+ return params .not_a_term
1005+ #ifdef FEAT_GUI
1006+ || gui .in_use
1007+ #endif
1008+ ;
1009+ }
1010+
9981011
9991012// When TRUE in a safe state when starting to wait for a character.
10001013static int was_safe = FALSE;
@@ -1528,9 +1541,7 @@ getout(int exitval)
15281541#endif
15291542
15301543 // Position the cursor on the last screen line, below all the text
1531- #ifdef FEAT_GUI
1532- if (!gui .in_use )
1533- #endif
1544+ if (!is_not_a_term_or_gui ())
15341545 windgoto ((int )Rows - 1 , 0 );
15351546
15361547#if defined(FEAT_EVAL ) || defined(FEAT_SYN_HL )
@@ -1640,9 +1651,7 @@ getout(int exitval)
16401651 }
16411652
16421653 // Position the cursor again, the autocommands may have moved it
1643- #ifdef FEAT_GUI
1644- if (!gui .in_use )
1645- #endif
1654+ if (!is_not_a_term_or_gui ())
16461655 windgoto ((int )Rows - 1 , 0 );
16471656
16481657#ifdef FEAT_JOB_CHANNEL
Original file line number Diff line number Diff line change @@ -3343,7 +3343,7 @@ exit_scroll(void)
33433343 else
33443344 out_char ('\n' );
33453345 }
3346- else
3346+ else if (! is_not_a_term ())
33473347 {
33483348 restore_cterm_colors (); // get original colors back
33493349 msg_clr_eos_force (); // clear the rest of the display
@@ -3370,9 +3370,12 @@ mch_exit(int r)
33703370 {
33713371 settmode (TMODE_COOK );
33723372#ifdef FEAT_TITLE
3373- // restore xterm title and icon name
3374- mch_restore_title (SAVE_RESTORE_BOTH );
3375- term_pop_title (SAVE_RESTORE_BOTH );
3373+ if (!is_not_a_term ())
3374+ {
3375+ // restore xterm title and icon name
3376+ mch_restore_title (SAVE_RESTORE_BOTH );
3377+ term_pop_title (SAVE_RESTORE_BOTH );
3378+ }
33763379#endif
33773380 /*
33783381 * When t_ti is not empty but it doesn't cause swapping terminal
Original file line number Diff line number Diff line change @@ -1043,6 +1043,32 @@ func Test_io_not_a_terminal()
10431043 \ ' Vim: Warning: Input is not from a terminal' ], l )
10441044endfunc
10451045
1046+ " Test for --not-a-term avoiding escape codes.
1047+ func Test_not_a_term ()
1048+ CheckUnix
1049+ CheckNotGui
1050+
1051+ if &shellredir = ~ ' %s'
1052+ let redir = printf (&shellredir , ' Xvimout' )
1053+ else
1054+ let redir = &shellredir .. ' Xvimout'
1055+ endif
1056+
1057+ " Without --not-a-term there are a few escape sequences.
1058+ " This will take 2 seconds because of the missing --not-a-term
1059+ let cmd = GetVimProg () .. ' --cmd quit ' .. redir
1060+ exe " silent !" . cmd
1061+ call assert_match (" \<Esc> " , readfile (' Xvimout' )- >join ())
1062+ call delete (' Xvimout' )
1063+
1064+ " With --not-a-term there are no escape sequences.
1065+ let cmd = GetVimProg () .. ' --not-a-term --cmd quit ' .. redir
1066+ exe " silent !" . cmd
1067+ call assert_notmatch (" \<Esc> " , readfile (' Xvimout' )- >join ())
1068+ call delete (' Xvimout' )
1069+ endfunc
1070+
1071+
10461072" Test for the "-w scriptout" argument
10471073func Test_w_arg ()
10481074 " Can't catch the output of gvim.
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+ 2662 ,
753755/**/
754756 2661 ,
755757/**/
You can’t perform that action at this time.
0 commit comments