diff src/os_unix.c @ 22514:d0dd03c04140 v8.2.1805

patch 8.2.1805: Unix: terminal mode changed when using ":shell" Commit: https://github.com/vim/vim/commit/80361a5f2b134c88597d60b3d363b52084e712a1 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Oct 5 21:39:25 2020 +0200 patch 8.2.1805: Unix: terminal mode changed when using ":shell" Problem: Unix: terminal mode changed when using ":shell". Solution: Avoid calling settmode() when not needed. (issue https://github.com/vim/vim/issues/7079)
author Bram Moolenaar <Bram@vim.org>
date Mon, 05 Oct 2020 21:45:03 +0200
parents 900737f2ee98
children 0f205ff4a0fd
line wrap: on
line diff
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -585,6 +585,7 @@ mch_total_mem(int special UNUSED)
 mch_delay(long msec, int flags)
 {
     tmode_T	old_tmode;
+    int		call_settmode;
 #ifdef FEAT_MZSCHEME
     long	total = msec; // remember original value
 #endif
@@ -596,10 +597,13 @@ mch_delay(long msec, int flags)
 	// shell may produce SIGQUIT).
 	// Only do this if sleeping for more than half a second.
 	in_mch_delay = TRUE;
-	old_tmode = mch_cur_tmode;
-	if (mch_cur_tmode == TMODE_RAW
-			       && (msec > 500 || (flags & MCH_DELAY_SETTMODE)))
+	call_settmode = mch_cur_tmode == TMODE_RAW
+			       && (msec > 500 || (flags & MCH_DELAY_SETTMODE));
+	if (call_settmode)
+	{
+	    old_tmode = mch_cur_tmode;
 	    settmode(TMODE_SLEEP);
+	}
 
 	/*
 	 * Everybody sleeps in a different way...
@@ -653,7 +657,7 @@ mch_delay(long msec, int flags)
 	while (total > 0);
 #endif
 
-	if (msec > 500 || (flags & MCH_DELAY_SETTMODE))
+	if (call_settmode)
 	    settmode(old_tmode);
 	in_mch_delay = FALSE;
     }