aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/event/proc.c6
-rw-r--r--src/nvim/ui_client.c3
-rw-r--r--test/functional/terminal/tui_spec.lua55
3 files changed, 53 insertions, 11 deletions
diff --git a/src/nvim/event/proc.c b/src/nvim/event/proc.c
index 2955693687..e32bbbc29a 100644
--- a/src/nvim/event/proc.c
+++ b/src/nvim/event/proc.c
@@ -438,9 +438,9 @@ static void on_proc_exit(Proc *proc)
ILOG("child exited: pid=%d status=%d" PRIu64, proc->pid, proc->status);
// XXX: This assumes the TUI never spawns any other processes...?
- // if (ui_client_channel_id) {
- // exit_on_closed_chan(proc->status);
- // }
+ if (ui_client_channel_id) {
+ exit_on_closed_chan(proc->status);
+ }
// Process has terminated, but there could still be data to be read from the
// OS. We are still in the libuv loop, so we cannot call code that polls for
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c
index d42c0a7fdd..44fc645a04 100644
--- a/src/nvim/ui_client.c
+++ b/src/nvim/ui_client.c
@@ -62,7 +62,8 @@ uint64_t ui_client_start_server(int argc, char **argv)
on_err.fwd_err = true;
#ifdef MSWIN
- bool detach = false; // TODO(justinmk): detach=true breaks `tt.setup_child_nvim` tests on Windows.
+ // TODO(justinmk): detach breaks `tt.setup_child_nvim` tests on Windows?
+ bool detach = os_env_exists("__NVIM_DETACH");
#else
bool detach = true;
#endif
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 011f3458b0..e2adcb66df 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -42,6 +42,47 @@ describe('TUI :detach', function()
end)
it('does not stop server', function()
+ local job_opts = {
+ env = {
+ NVIM_LOG_FILE = testlog,
+ },
+ }
+
+ if is_os('win') then
+ -- TODO(justinmk): on Windows,
+ -- - tt.setup_child_nvim() is broken.
+ -- - session.lua is broken after the pipe closes.
+ -- So this test currently just exercises __NVIM_DETACH + :detach, without asserting anything.
+
+ -- TODO(justinmk): temporary hack for Windows.
+ job_opts.env['__NVIM_DETACH'] = '1'
+ n.clear(job_opts)
+
+ local screen = Screen.new(50, 10)
+ n.feed('iHello, World')
+ screen:expect([[
+ Hello, World^ |
+ {1:~ }|*8
+ {5:-- INSERT --} |
+ ]])
+
+ -- local addr = api.nvim_get_vvar('servername')
+ eq(1, #n.api.nvim_list_uis())
+
+ -- TODO(justinmk): test util should not freak out when the pipe closes.
+ n.expect_exit(n.command, 'detach')
+
+ -- n.get_session():close() -- XXX: hangs
+ -- n.set_session(n.connect(addr)) -- XXX: hangs
+ -- eq(0, #n.api.nvim_list_uis()) -- XXX: hangs
+
+ -- Avoid a dangling process.
+ n.get_session():close('kill')
+ -- n.expect_exit(n.command, 'qall!')
+
+ return
+ end
+
local server_super = n.clear()
local client_super = n.new_session(true)
finally(function()
@@ -53,16 +94,15 @@ describe('TUI :detach', function()
local screen = tt.setup_child_nvim({
'--listen',
child_server,
- '--clean',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
'--cmd',
'colorscheme vim',
'--cmd',
nvim_set .. ' notermguicolors laststatus=2 background=dark',
- }, {
- env = {
- NVIM_LOG_FILE = testlog,
- },
- })
+ }, job_opts)
tt.feed_data('iHello, World')
screen:expect {
@@ -106,7 +146,8 @@ describe('TUI :detach', function()
'--remote-ui',
'--server',
child_server,
- })
+ }, job_opts)
+
screen_reattached:expect {
grid = [[
We did it, pooky^. |