diff options
-rw-r--r-- | src/nvim/main.c | 6 | ||||
-rw-r--r-- | src/nvim/os/os_win_conpty.c | 17 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index 33c0466e1a..c7011f4f4e 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -46,9 +46,6 @@ #include "nvim/option.h" #include "nvim/os_unix.h" #include "nvim/os/os_defs.h" -#ifdef WIN32 -# include "nvim/os/os_win_conpty.h" -#endif #include "nvim/path.h" #include "nvim/profile.h" #include "nvim/popupmnu.h" @@ -229,9 +226,6 @@ void early_init(void) init_signs(); ui_comp_syn_init(); -#ifdef WIN32 - os_dyn_conpty_init(); -#endif } #ifdef MAKE_LIB diff --git a/src/nvim/os/os_win_conpty.c b/src/nvim/os/os_win_conpty.c index a73b1b65a0..3d5ba83523 100644 --- a/src/nvim/os/os_win_conpty.c +++ b/src/nvim/os/os_win_conpty.c @@ -14,23 +14,26 @@ # define PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE 0x00020016 #endif -static bool conpty_working = false; - HRESULT (WINAPI *pCreatePseudoConsole)(COORD, HANDLE, HANDLE, DWORD, HPCON *); HRESULT (WINAPI *pResizePseudoConsole)(HPCON, COORD); void (WINAPI *pClosePseudoConsole)(HPCON); bool os_has_conpty_working(void) { - return conpty_working; + static TriState has_conpty = kNone; + if (has_conpty == kNone) { + has_conpty = os_dyn_conpty_init(); + } + + return has_conpty == kTrue; } -void os_dyn_conpty_init(void) +TriState os_dyn_conpty_init(void) { uv_lib_t kernel; if (uv_dlopen("kernel32.dll", &kernel)) { uv_dlclose(&kernel); - return; + return kFalse; } static struct { char *name; @@ -45,10 +48,10 @@ void os_dyn_conpty_init(void) conpty_entry[i].name != NULL && conpty_entry[i].ptr != NULL; i++) { if (uv_dlsym(&kernel, conpty_entry[i].name, (void **)conpty_entry[i].ptr)) { uv_dlclose(&kernel); - return; + return kFalse; } } - conpty_working = true; + return kTrue; } conpty_t *os_conpty_init(char **in_name, char **out_name, |