Hi bram.
This is counter patch to fix this. This patch stop calling of
SetConsoleActiveScreenBuffer to switch buffer. And do calling it for passing
duplicated handle to external process on windows7. I and few people who use
wnidows7 tried this patch. It seems good to me.
* Solved window flicking
* Fixed issue of :echo map(range(10), 'system("echo ". v:val)')
* test11 passed
* test47 passed
- mattn
https://gist.github.com/c2237410b3a7853e2b11
diff --git a/src/os_win32.c b/src/os_win32.c
index 6981d2f..57feae6 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4614,18 +4614,31 @@ mch_system(char *cmd, int options)
int ret;
/*
- * Restore non-termcap screen buffer before execute external program, and
- * revert it after. Because msys and msys2's programs will cause freeze
- * or crash conhost.exe (Windows's console window provider) and vim.exe,
- * if active screen buffer is vim's one on Windows7.
+ * Call DuplicateHandle before execute external program. Because msys and
+ * msys2's programs will call CreateConsoleScreenBuffer and CloseHandle.
+ * CreateConsoleScreenBuffer return same handle which created by vim.
+ * So it occurs crash. This workaround is required on Windows7.
*/
+ HANDLE hTemp = INVALID_HANDLE_VALUE;
if (is_win7 && g_fTermcapMode)
- SetConsoleActiveScreenBuffer(g_cbNonTermcap.handle);
+ {
+ if (DuplicateHandle(
+ GetCurrentProcess(),
+ g_hConOut,
+ GetCurrentProcess(),
+ &hTemp,
+ 0,
+ TRUE,DUPLICATE_SAME_ACCESS)) {
+ SetConsoleActiveScreenBuffer(hTemp);
+ }
+ }
ret = mch_system1(cmd, options);
- if (is_win7 && g_fTermcapMode)
- SetConsoleActiveScreenBuffer(g_cbTermcap.handle);
+ if (hTemp != INVALID_HANDLE_VALUE) {
+ SetConsoleActiveScreenBuffer(g_hConOut);
+ CloseHandle(hTemp);
+ }
return ret;
}
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.