diff --git a/src/nvim/channel.c b/src/nvim/channel.c index dcd422aa13..203bdbe680 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -563,19 +563,13 @@ uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, const char **err if (embedded_mode && os_has_conpty_working()) { stdin_dup_fd = os_dup_cloexec(STDIN_FILENO); stdout_dup_fd = os_dup_cloexec(STDOUT_FILENO); - // :restart spawns a replacement server that must not borrow the parent - // Nvim process console, because that parent process will soon exit. - const bool restart_alloc_console = os_env_exists(ENV_RESTART_ALLOC_CONSOLE, true); - if (restart_alloc_console) { - os_unsetenv(ENV_RESTART_ALLOC_CONSOLE); - } if (!GetConsoleWindow()) { // Borrow the parent's console so CONOUT$ resolves to the real terminal, - // preserving io.stdout rendering (e.g. SIXEL/Kitty images). Only fall - // back to a hidden AllocConsole when there is no parent console (e.g. - // launched from a non-console parent), or for the replacement server - // spawned by :restart, because the parent Nvim process will soon exit. - if (restart_alloc_console || !AttachConsole(ATTACH_PARENT_PROCESS)) { + // preserving io.stdout rendering (e.g. SIXEL/Kitty images). A replacement + // server started by :restart can reuse the current server's console. + // Only fall back to a hidden console when the parent has no console. + if (!AttachConsole(ATTACH_PARENT_PROCESS)) { + ILOG("parent console attach failed: %lu; allocating hidden console", GetLastError()); AllocConsole(); ShowWindow(GetConsoleWindow(), SW_HIDE); } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 6cb539deb7..7dd4a108f5 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5079,9 +5079,6 @@ static void ex_restart(exarg_T *eap) dict_T *env = create_environment(NULL, false, false, false, NULL); tv_dict_add_str(env, S_LEN(ENV_STARTREASON), startreason); -#ifdef MSWIN - tv_dict_add_str(env, S_LEN(ENV_RESTART_ALLOC_CONSOLE), "1"); -#endif CallbackReader on_err = CALLBACK_READER_INIT; #ifdef MSWIN diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h index d9677cb58b..af8872a8a5 100644 --- a/src/nvim/os/os.h +++ b/src/nvim/os/os.h @@ -27,6 +27,5 @@ extern char *default_lib_dir; #define ENV_LOGFILE "NVIM_LOG_FILE" #define ENV_LOGFILE_WANT "__NVIM_LOG_FILE_WANT" #define ENV_NVIM "NVIM" -#define ENV_RESTART_ALLOC_CONSOLE "__NVIM_RESTART_ALLOC_CONSOLE" #define ENV_STARTREASON "__NVIM_STARTREASON" #define ENV_TEST_LOG "__NVIM_TEST_LOG"