0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 7.4.886

Problem:    Windows7: Switching screen buffer causes flicker when using
            system().
Solution:   Instead of actually switching screen buffer, duplicate the handle.
            (Yasuhiro Matsumoto)
This commit is contained in:
Bram Moolenaar
2015-09-29 14:01:12 +02:00
parent c79a5452ac
commit 1d478a6242
2 changed files with 24 additions and 8 deletions

View File

@@ -4612,20 +4612,34 @@ mch_system1(char *cmd, int options)
mch_system(char *cmd, int options) mch_system(char *cmd, int options)
{ {
int ret; int ret;
HANDLE hTemp = INVALID_HANDLE_VALUE;
/* /*
* Restore non-termcap screen buffer before execute external program, and * Call DuplicateHandle before executing an external program, because msys
* revert it after. Because msys and msys2's programs will cause freeze * and msys2's programs will call CreateConsoleScreenBuffer and
* or crash conhost.exe (Windows's console window provider) and vim.exe, * CloseHandle. CreateConsoleScreenBuffer returns the same handle which
* if active screen buffer is vim's one on Windows7. * created by vim. This causes a crash. This workaround is required on
* Windows7.
*/ */
if (is_win7 && g_fTermcapMode) if (is_win7
SetConsoleActiveScreenBuffer(g_cbNonTermcap.handle); && g_fTermcapMode
&& DuplicateHandle(
GetCurrentProcess(),
g_hConOut,
GetCurrentProcess(),
&hTemp,
0,
TRUE,
DUPLICATE_SAME_ACCESS))
SetConsoleActiveScreenBuffer(hTemp);
ret = mch_system1(cmd, options); ret = mch_system1(cmd, options);
if (is_win7 && g_fTermcapMode) if (hTemp != INVALID_HANDLE_VALUE)
SetConsoleActiveScreenBuffer(g_cbTermcap.handle); {
SetConsoleActiveScreenBuffer(g_hConOut);
CloseHandle(hTemp);
}
return ret; return ret;
} }

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
886,
/**/ /**/
885, 885,
/**/ /**/