diff src/os_win32.c @ 6290:e0f2ed0efb49 v7.4.479

updated for version 7.4.479 Problem: MS-Windows: The console title can be wrong. Solution: Take the encoding into account. When restoring the title use the right function. (Yasuhiro Matsumoto)
author Bram Moolenaar <bram@vim.org>
date Wed, 15 Oct 2014 22:50:10 +0200
parents 452e8b2a0ab3
children e3149e2b4152
line wrap: on
line diff
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4648,6 +4648,35 @@ mch_call_shell(
 #ifdef FEAT_TITLE
     char szShellTitle[512];
 
+# ifdef FEAT_MBYTE
+    /* Change the title to reflect that we are in a subshell. */
+    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+    {
+	WCHAR szShellTitle[512];
+
+	if (GetConsoleTitleW(szShellTitle,
+				  sizeof(szShellTitle)/sizeof(WCHAR) - 4) > 0)
+	{
+	    if (cmd == NULL)
+		wcscat(szShellTitle, L" :sh");
+	    else
+	    {
+		WCHAR *wn = enc_to_utf16(cmd, NULL);
+
+		if (wn != NULL)
+		{
+		    wcscat(szShellTitle, L" - !");
+		    if ((wcslen(szShellTitle) + wcslen(wn) <
+					  sizeof(szShellTitle)/sizeof(WCHAR)))
+			wcscat(szShellTitle, wn);
+		    SetConsoleTitleW(szShellTitle);
+		    vim_free(wn);
+		    goto didset;
+		}
+	    }
+	}
+    }
+#endif
     /* Change the title to reflect that we are in a subshell. */
     if (GetConsoleTitle(szShellTitle, sizeof(szShellTitle) - 4) > 0)
     {
@@ -4659,7 +4688,7 @@ mch_call_shell(
 	    if ((strlen(szShellTitle) + strlen(cmd) < sizeof(szShellTitle)))
 		strcat(szShellTitle, cmd);
 	}
-	mch_settitle(szShellTitle, NULL);
+	SetConsoleTitle(szShellTitle);
     }
 #endif