diff src/terminal.c @ 15844:63e71d195cee v8.1.0929

patch 8.1.0929: no error when requesting ConPTY but it's not available commit https://github.com/vim/vim/commit/5acd9872580a12ca1138275bf65d1cb9349e2a53 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 16 13:35:13 2019 +0100 patch 8.1.0929: no error when requesting ConPTY but it's not available Problem: No error when requesting ConPTY but it's not available. Solution: Add an error message. (Hirohito Higashi, closes https://github.com/vim/vim/issues/3967)
author Bram Moolenaar <Bram@vim.org>
date Sat, 16 Feb 2019 13:45:07 +0100
parents 85c94163c4ab
children 7fad90423bd2
line wrap: on
line diff
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -5620,10 +5620,8 @@ void (WINAPI *pDeleteProcThreadAttribute
     static int
 dyn_conpty_init(int verbose)
 {
-    static BOOL	handled = FALSE;
-    static int	result;
-    HMODULE	hKerneldll;
-    int		i;
+    static HMODULE	hKerneldll = NULL;
+    int			i;
     static struct
     {
 	char	*name;
@@ -5642,16 +5640,17 @@ dyn_conpty_init(int verbose)
 	{NULL, NULL}
     };
 
-    if (handled)
-	return result;
-
     if (!has_conpty_working())
     {
-	handled = TRUE;
-	result = FAIL;
+	if (verbose)
+	    emsg(_("E982: ConPTY is not available"));
 	return FAIL;
     }
 
+    // No need to initialize twice.
+    if (hKerneldll)
+	return OK;
+
     hKerneldll = vimLoadLib("kernel32.dll");
     for (i = 0; conpty_entry[i].name != NULL
 					&& conpty_entry[i].ptr != NULL; ++i)
@@ -5661,12 +5660,11 @@ dyn_conpty_init(int verbose)
 	{
 	    if (verbose)
 		semsg(_(e_loadfunc), conpty_entry[i].name);
+	    hKerneldll = NULL;
 	    return FAIL;
 	}
     }
 
-    handled = TRUE;
-    result = OK;
     return OK;
 }
 
@@ -6015,6 +6013,7 @@ dyn_winpty_init(int verbose)
 	{
 	    if (verbose)
 		semsg(_(e_loadfunc), winpty_entry[i].name);
+	    hWinPtyDLL = NULL;
 	    return FAIL;
 	}
     }