fix(channel): support :detach, :restart on Windows #37977

fix: allocate hidden console for detached server

Starting the server with UV_PROCESS_DETACHED results in DETACHED_PROCESS, leaving the child without a console. Without a console:

CONIN$ / CONOUT$ cannot resolve, causing channel_from_stdio to fail.

ConPTY cannot attach, breaking :terminal.

This patch allocates a hidden console via AllocConsole() when the server has none, restoring working stdio and enabling ConPTY.

Also updates os_set_cloexec to clear HANDLE_FLAG_INHERIT on the RPC pipe
handles, matching the Unix F_DUPFD_CLOEXEC behavior.
This commit is contained in:
Sanzhar Kuandyk
2026-02-28 18:21:13 +05:00
committed by GitHub
parent 5943a81fe7
commit b40ca5a01c
6 changed files with 107 additions and 66 deletions

View File

@@ -8,6 +8,7 @@
-- - NOTE: Only use this if your test actually needs the full lifecycle/capabilities of the
-- builtin Nvim TUI. Most tests should just use `Screen.new()` directly, or plain old API calls.
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
@@ -207,4 +208,17 @@ function M.setup_child_nvim(args, opts)
return M.setup_screen(opts.extra_rows, argv, opts.cols, env)
end
--- FIXME: On Windows spaces at the end of a screen line may have wrong attrs.
--- Remove this function when that's fixed.
---
--- @param screen test.functional.ui.screen
--- @param s string
function M.screen_expect(screen, s)
if t.is_os('win') then
s = s:gsub(' *%} +%|\n', '{MATCH: *}}{MATCH: *}|\n')
s = s:gsub('%}%^ +%|\n', '{MATCH:[ ^]*}}{MATCH:[ ^]*}|\n')
end
screen:expect(s)
end
return M