From 8ef41f590224dfeea2e51d9fec150e363fd72ee0 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 19 Dec 2024 07:07:04 -0800 Subject: feat(jobs): jobstart(…,{term=true}), deprecate termopen() #31343 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: `termopen` has long been a superficial wrapper around `jobstart`, and has no real purpose. Also, `vim.system` and `nvim_open_term` presumably will replace all features of `jobstart` and `termopen`, so centralizing the logic will help with that. Solution: - Introduce `eval/deprecated.c`, where all deprecated eval funcs will live. - Introduce "term" flag of `jobstart`. - Deprecate `termopen`. --- test/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 2820cc9663..7234985009 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -115,7 +115,8 @@ describe("preserve and (R)ecover with custom 'directory'", function() t.skip(t.is_os('win')) local screen0 = Screen.new() local child_server = new_pipename() - fn.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server }, { + fn.jobstart({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, }) screen0:expect({ any = pesc('[No Name]') }) -- Wait for the child process to start. @@ -446,9 +447,10 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() end) it('(Q)uit at first file argument', function() - local chan = fn.termopen( + local chan = fn.jobstart( { nvim_prog, '-u', 'NONE', '-i', 'NONE', '--cmd', init_dir, '--cmd', init_set, testfile }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, } ) @@ -468,7 +470,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() end) it('(A)bort at second file argument with -p', function() - local chan = fn.termopen({ + local chan = fn.jobstart({ nvim_prog, '-u', 'NONE', @@ -482,6 +484,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() otherfile, testfile, }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, }) retry(nil, nil, function() @@ -508,7 +511,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() second %s /^ \zssecond$/ third %s /^ \zsthird$/]]):format(testfile, testfile, testfile) ) - local chan = fn.termopen({ + local chan = fn.jobstart({ nvim_prog, '-u', 'NONE', @@ -522,6 +525,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() 'set tags=' .. otherfile, '-tsecond', }, { + term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, }) retry(nil, nil, function() -- cgit From 48e2a73610ca5639408f79b3d8eebd3e5f57a327 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Thu, 2 Jan 2025 14:51:03 +0100 Subject: feat(ui)!: emit prompt "messages" as cmdline events #31525 Problem: Prompts are emitted as messages events, where cmdline events are more appropriate. The user input is also emitted as message events in fast context, so cannot be displayed with vim.ui_attach(). Solution: Prompt for user input through cmdline prompts. --- test/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 7234985009..08f7663075 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -220,6 +220,7 @@ describe('swapfile detection', function() .. [[%.swp"]], } feed('e') -- Chose "Edit" at the swap dialog. + screen2:expect({ any = pesc('E5555: API call: Vim(edit):E325: ATTENTION') }) feed('') screen2:expect(expected_no_dialog) @@ -535,10 +536,6 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() ) end) api.nvim_chan_send(chan, 'q') - retry(nil, nil, function() - eq('Press ENTER or type command to continue', eval("getline('$')->trim(' ', 2)")) - end) - api.nvim_chan_send(chan, '\r') retry(nil, nil, function() eq( { '', '[Process exited 1]', '' }, -- cgit From 64b0e6582ae8c273efbe39109bcb261079c2bcd4 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 4 Jan 2025 16:48:00 -0800 Subject: refactor(tests): merge n.spawn/n.spawn_argv into n.new_session #31859 Problem: - `n.spawn()` is misleading because it also connects RPC, it's not just "spawning" a process. - It's confusing that `n.spawn()` and `n.spawn_argv()` are separate. Solution: - Replace `n.spawn()`/`n.spawn_argv()` with a single function `n.new_session()`. This name aligns with the existing functions `n.set_session`/`n.get_session`. - Note: removes direct handling of `prepend_argv`, but I doubt that was important or intentional. If callers want to control use of `prepend_argv` then we should add a new flag to `test.session.Opts`. - Move `keep` to first parameter of `n.new_session()`. - Add a `merge` flag to `test.session.Opts` - Mark `_new_argv()` as private. Test should use clear/new_session/spawn_wait instead. --- .../ex_cmds/swapfile_preserve_recover_spec.lua | 18 +++++++++--------- test/functional/ex_cmds/wundo_spec.lua | 16 +++++----------- 2 files changed, 14 insertions(+), 20 deletions(-) (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 08f7663075..d1f598a9d8 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -12,12 +12,10 @@ local fn = n.fn local nvim_prog = n.nvim_prog local ok = t.ok local rmdir = n.rmdir -local new_argv = n.new_argv local new_pipename = n.new_pipename local pesc = vim.pesc local os_kill = n.os_kill local set_session = n.set_session -local spawn = n.spawn local async_meths = n.async_meths local expect_msg_seq = n.expect_msg_seq local pcall_err = t.pcall_err @@ -56,7 +54,7 @@ describe("preserve and (R)ecover with custom 'directory'", function() local nvim0 before_each(function() - nvim0 = spawn(new_argv()) + nvim0 = n.new_session(false) set_session(nvim0) rmdir(swapdir) mkdir(swapdir) @@ -76,7 +74,8 @@ describe("preserve and (R)ecover with custom 'directory'", function() local function test_recover(swappath1) -- Start another Nvim instance. - local nvim2 = spawn({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed' }, true) + local nvim2 = + n.new_session(false, { args = { '-u', 'NONE', '-i', 'NONE', '--embed' }, merge = false }) set_session(nvim2) exec(init) @@ -141,7 +140,7 @@ describe('swapfile detection', function() set swapfile fileformat=unix nomodified undolevels=-1 nohidden ]] before_each(function() - nvim0 = spawn(new_argv()) + nvim0 = n.new_session(false) set_session(nvim0) rmdir(swapdir) mkdir(swapdir) @@ -168,7 +167,8 @@ describe('swapfile detection', function() command('preserve') -- Start another Nvim instance. - local nvim2 = spawn({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed' }, true, nil, true) + local nvim2 = + n.new_session(true, { args = { '-u', 'NONE', '-i', 'NONE', '--embed' }, merge = false }) set_session(nvim2) local screen2 = Screen.new(256, 40) screen2._default_attr_ids = nil @@ -251,7 +251,7 @@ describe('swapfile detection', function() command('preserve') -- Make sure the swap file exists. local nvimpid = fn.getpid() - local nvim1 = spawn(new_argv(), true, nil, true) + local nvim1 = n.new_session(true) set_session(nvim1) local screen = Screen.new(75, 18) exec(init) @@ -273,7 +273,7 @@ describe('swapfile detection', function() [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg }) - local nvim1 = spawn(new_argv(), true, nil, true) + local nvim1 = n.new_session(true) set_session(nvim1) screen:attach() exec(init) @@ -292,7 +292,7 @@ describe('swapfile detection', function() ]]) nvim1:close() - local nvim2 = spawn(new_argv(), true, nil, true) + local nvim2 = n.new_session(true) set_session(nvim2) screen:attach() exec(init) diff --git a/test/functional/ex_cmds/wundo_spec.lua b/test/functional/ex_cmds/wundo_spec.lua index 2299f33f06..9b81c6d06d 100644 --- a/test/functional/ex_cmds/wundo_spec.lua +++ b/test/functional/ex_cmds/wundo_spec.lua @@ -5,8 +5,6 @@ local n = require('test.functional.testnvim')() local command = n.command local clear = n.clear local eval = n.eval -local spawn = n.spawn -local nvim_prog = n.nvim_prog local set_session = n.set_session describe(':wundo', function() @@ -24,15 +22,11 @@ end) describe('u_* functions', function() it('safely fail on new, non-empty buffer', function() - local session = spawn({ - nvim_prog, - '-u', - 'NONE', - '-i', - 'NONE', - '--embed', - '-c', - 'set undodir=. undofile', + local session = n.new_session(false, { + args = { + '-c', + 'set undodir=. undofile', + }, }) set_session(session) command('echo "True"') -- Should not error out due to crashed Neovim -- cgit From 09e01437c968be4c6e9f6bb3ac8811108c58008c Mon Sep 17 00:00:00 2001 From: Maria José Solano Date: Mon, 13 Jan 2025 19:45:11 -0800 Subject: refactor: use nvim.foo.bar format for autocommand groups --- test/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/ex_cmds') diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index d1f598a9d8..f84fc140d2 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -173,7 +173,7 @@ describe('swapfile detection', function() local screen2 = Screen.new(256, 40) screen2._default_attr_ids = nil exec(init) - command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). + command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog). -- With shortmess+=F command('set shortmess+=F') @@ -277,7 +277,7 @@ describe('swapfile detection', function() set_session(nvim1) screen:attach() exec(init) - command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). + command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog). feed(':split Xfile1\n') -- The default SwapExists handler does _not_ skip this prompt. screen:expect({ @@ -296,7 +296,7 @@ describe('swapfile detection', function() set_session(nvim2) screen:attach() exec(init) - command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). + command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog). command('set more') command('au bufadd * let foo_w = wincol()') feed(':e Xfile1') @@ -327,7 +327,7 @@ describe('swapfile detection', function() exec(init) if not swapexists then - command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). + command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog). end command('set nohidden') -- cgit