# HG changeset patch # User Bram Moolenaar # Date 1589664603 -7200 # Node ID 3bb4dea4a164e48acd8935a8c29414dd77d2e0e5 # Parent d64dba8d8a9d834ae3d2ed5107fba41c0d35e1b9 patch 8.2.0773: switching to raw mode every time ":" is used Commit: https://github.com/vim/vim/commit/3b1f18f785f67c6cd110498c366e4d0c0fe11f27 Author: Bram Moolenaar Date: Sat May 16 23:15:08 2020 +0200 patch 8.2.0773: switching to raw mode every time ":" is used Problem: Switching to raw mode every time ":" is used. Solution: When executing a shell set cur_tmode to TMODE_UNKNOWN, so that the next time TMODE_RAW is used it is set, but not every time. diff --git a/src/os_amiga.c b/src/os_amiga.c --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -1387,7 +1387,11 @@ mch_call_shell( if ((mydir = CurrentDir(mydir)) != 0) // make sure we stay in the same directory UnLock(mydir); if (tmode == TMODE_RAW) + { + // The shell may have messed with the mode, always set it. + cur_tmode = TMODE_UNKNOWN; settmode(TMODE_RAW); // set to raw mode + } #ifdef FEAT_TITLE resettitle(); #endif diff --git a/src/os_unix.c b/src/os_unix.c --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4521,7 +4521,11 @@ mch_call_shell_system( } if (tmode == TMODE_RAW) + { + // The shell may have messed with the mode, always set it. + cur_tmode = TMODE_UNKNOWN; settmode(TMODE_RAW); // set to raw mode + } # ifdef FEAT_TITLE resettitle(); # endif @@ -4571,6 +4575,9 @@ mch_call_shell_fork( out_flush(); if (options & SHELL_COOKED) settmode(TMODE_COOK); // set to normal mode + if (tmode == TMODE_RAW) + // The shell may have messed with the mode, always set it later. + cur_tmode = TMODE_UNKNOWN; if (unix_build_argv(cmd, &argv, &tofree1, &tofree2) == FAIL) goto error; diff --git a/src/os_win32.c b/src/os_win32.c --- a/src/os_win32.c +++ b/src/os_win32.c @@ -4899,7 +4899,11 @@ mch_call_shell( } if (tmode == TMODE_RAW) + { + // The shell may have messed with the mode, always set it. + cur_tmode = TMODE_UNKNOWN; settmode(TMODE_RAW); // set to raw mode + } // Print the return value, unless "vimrun" was used. if (x != 0 && !(options & SHELL_SILENT) && !emsg_silent diff --git a/src/term.c b/src/term.c --- a/src/term.c +++ b/src/term.c @@ -2862,7 +2862,7 @@ term_color(char_u *s, int n) #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) || (s[0] == ESC && s[1] == '|') #endif - || (s[0] == CSI && (i = 1) == 1)) + || (s[0] == CSI && (i = 1) == 1)) && s[i] != NUL && (STRCMP(s + i + 1, "%p1%dm") == 0 || STRCMP(s + i + 1, "%dm") == 0) @@ -3447,14 +3447,14 @@ settmode(int tmode) if (full_screen) { /* - * When returning after calling a shell we want to really set the - * terminal to raw mode, even though we think it already is, because - * the shell program may have reset the terminal mode. + * When returning after calling a shell cur_tmode is TMODE_UNKNOWN, + * set the terminal to raw mode, even though we think it already is, + * because the shell program may have reset the terminal mode. * When we think the terminal is normal, don't try to set it to * normal again, because that causes problems (logout!) on some * machines. */ - if (tmode != TMODE_COOK || cur_tmode != TMODE_COOK) + if (tmode != cur_tmode) { #ifdef FEAT_TERMRESPONSE # ifdef FEAT_GUI diff --git a/src/term.h b/src/term.h --- a/src/term.h +++ b/src/term.h @@ -209,6 +209,7 @@ extern char_u *(term_strings[]); // c #define T_SSI (TERM_STR(KS_SSI)) // save icon text #define T_SRI (TERM_STR(KS_SRI)) // restore icon text -#define TMODE_COOK 0 // terminal mode for external cmds and Ex mode -#define TMODE_SLEEP 1 // terminal mode for sleeping (cooked but no echo) -#define TMODE_RAW 2 // terminal mode for Normal and Insert mode +#define TMODE_COOK 0 // terminal mode for external cmds and Ex mode +#define TMODE_SLEEP 1 // terminal mode for sleeping (cooked but no echo) +#define TMODE_RAW 2 // terminal mode for Normal and Insert mode +#define TMODE_UNKNOWN 9 // after executing a shell diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 773, +/**/ 772, /**/ 771,