From 55defa1a41baac65cd32dc499b330af9751d6c5b Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Mon, 16 Aug 2021 21:06:49 -0600 Subject: fix(terminal): close without ! if the job is stopped - If the terminal job is still running then ! is still required. Closes #4683 --- test/functional/terminal/buffer_spec.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test/functional/terminal/buffer_spec.lua') diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index c61bf108cb..16f7fe5178 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -7,6 +7,12 @@ local eq, neq = helpers.eq, helpers.neq local write_file = helpers.write_file local command= helpers.command local exc_exec = helpers.exc_exec +local retry = helpers.retry +local funcs = helpers.funcs +local pesc = helpers.pesc +local matches = helpers.matches +local nvim_dir = helpers.nvim_dir +local iswin = helpers.iswin describe(':terminal buffer', function() local screen @@ -255,8 +261,14 @@ describe(':terminal buffer', function() command('bdelete!') end) - it('handles wqall', function() + it("requires bang (!) to close a running job", function() + local cwd = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') + local ext_pat = iswin() and '%.EXE' or '' eq('Vim(wqall):E948: Job still running', exc_exec('wqall')) + matches('^Vim%(bdelete%):E89: term://'..pesc(cwd)..'//%d+:'..nvim_dir..'/tty%-test'..ext_pat..' will be killed %(add %! to override%)$', exc_exec('bdelete')) + command('call jobstop(&channel)') + retry(nil, nil, function() assert(0 >= eval('jobwait([&channel], 1000)[0]')) end) + command('bdelete') end) it('does not segfault when pasting empty buffer #13955', function() -- cgit From 3c081d028062f793b63b8689f854bbea30e15752 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Sat, 28 Aug 2021 09:58:27 -0600 Subject: fix(jobwait): always drain process event queues #15402 Problem: jobwait() returns early if the job was stopped, but the job might have pending callbacks on its event queue which are required to complete its teardown. State such as term->closed might not be updated yet (by the pending callbacks), so codepaths such as :bdelete think the job is still running. Solution: Always flush the job's event queue before returning from jobwait(). ref #15349 --- test/functional/terminal/buffer_spec.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'test/functional/terminal/buffer_spec.lua') diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 16f7fe5178..c0af932e68 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -7,12 +7,7 @@ local eq, neq = helpers.eq, helpers.neq local write_file = helpers.write_file local command= helpers.command local exc_exec = helpers.exc_exec -local retry = helpers.retry -local funcs = helpers.funcs -local pesc = helpers.pesc local matches = helpers.matches -local nvim_dir = helpers.nvim_dir -local iswin = helpers.iswin describe(':terminal buffer', function() local screen @@ -261,16 +256,25 @@ describe(':terminal buffer', function() command('bdelete!') end) - it("requires bang (!) to close a running job", function() - local cwd = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') - local ext_pat = iswin() and '%.EXE' or '' + it('requires bang (!) to close a running job #15402', function() eq('Vim(wqall):E948: Job still running', exc_exec('wqall')) - matches('^Vim%(bdelete%):E89: term://'..pesc(cwd)..'//%d+:'..nvim_dir..'/tty%-test'..ext_pat..' will be killed %(add %! to override%)$', exc_exec('bdelete')) + for _, cmd in ipairs({ 'bdelete', '%bdelete', 'bwipeout', 'bunload' }) do + matches('^Vim%('..cmd:gsub('%%', '')..'%):E89: term://.*tty%-test.* will be killed %(add %! to override%)$', + exc_exec(cmd)) + end command('call jobstop(&channel)') - retry(nil, nil, function() assert(0 >= eval('jobwait([&channel], 1000)[0]')) end) + assert(0 >= eval('jobwait([&channel], 1000)[0]')) command('bdelete') end) + it('stops running jobs with :quit', function() + -- Open in a new window to avoid terminating the nvim instance + command('split') + command('terminal') + command('set nohidden') + command('quit') + end) + it('does not segfault when pasting empty buffer #13955', function() feed_command('terminal') feed('') -- cgit