fix(:restart): specify ++nested in UIEnter (#38550)

This commit is contained in:
zeertzjq
2026-03-29 17:04:15 +08:00
committed by GitHub
parent ad4bc2d90c
commit 44a88a746f
2 changed files with 41 additions and 20 deletions

View File

@@ -5044,8 +5044,9 @@ static void ex_restart(exarg_T *eap)
if (*eap->arg != NUL) {
// Execute [command] on new server on UIEnter.
MAXSIZE_TEMP_DICT(autocmd_opts, 2);
MAXSIZE_TEMP_DICT(autocmd_opts, 3);
PUT_C(autocmd_opts, "once", BOOLEAN_OBJ(true));
PUT_C(autocmd_opts, "nested", BOOLEAN_OBJ(true));
PUT_C(autocmd_opts, "command", CSTR_AS_OBJ(eap->arg));
MAXSIZE_TEMP_ARRAY(autocmd_args, 2);
ADD_C(autocmd_args, CSTR_AS_OBJ("UIEnter"));

View File

@@ -210,17 +210,14 @@ describe('TUI :detach', function()
end)
describe('TUI :restart', function()
before_each(n.clear)
after_each(n.check_close)
it('validation', function()
clear()
eq('Vim(restart):E481: No range allowed: :1restart', t.pcall_err(n.command, ':1restart'))
end)
it('works', function()
clear()
finally(function()
n.check_close()
end)
local server_pipe = new_pipename()
local screen = tt.setup_child_nvim({
'-u',
@@ -409,13 +406,11 @@ describe('TUI :restart', function()
it('drops "-" and "-- [files…]" from v:argv #34417', function()
t.skip(is_os('win'), 'stdin behavior differs on Windows')
clear()
local server_session
finally(function()
if server_session then
server_session:close()
end
n.check_close()
end)
local server_pipe = new_pipename()
local screen = tt.setup_child_nvim({
@@ -433,7 +428,7 @@ describe('TUI :restart', function()
'--',
'Xtest-file1',
'Xtest-file2',
})
}, { env = env_notermguicolors })
screen:expect([[
^ |
~ |*3
@@ -470,9 +465,44 @@ describe('TUI :restart', function()
feed_data(':qall!\r')
screen:expect({ any = vim.pesc('[Process exited 0]') })
end)
it('autocommands are triggered by [command] properly #38549', function()
local screen = tt.setup_child_nvim({
'--clean',
'--cmd',
'autocmd FileType text echomsg "TRIGGERED: " .. bufnr()',
'--cmd',
'set notermguicolors noswapfile laststatus=0',
}, { env = env_notermguicolors })
screen:expect([[
^ |
~ |*4
0,0-1 All |
{5:-- TERMINAL --} |
]])
-- 'laststatus' should be 0 in the new Nvim and FileType event should be triggered.
feed_data(':restart set nowrap | edit test/functional/fixtures/bigfile.txt\r')
screen:expect([[
^0000;<control>;Cc;0;BN;;;;;N;NULL;;;; |
0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;;; |
0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; |
0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; |
0004;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSION;;|
TRIGGERED: 1 1,1 Top |
{5:-- TERMINAL --} |
]])
-- The server is now detached and needs to be quit explicitly.
feed_data(':qall!\r')
screen:expect({ any = vim.pesc('[Process exited 0]') })
end)
end)
describe('TUI :connect', function()
before_each(n.clear)
after_each(n.check_close)
local screen_empty = [[
^ |
{100:~ }|*5
@@ -480,11 +510,6 @@ describe('TUI :connect', function()
]]
it('leaves the current server running', function()
n.clear()
finally(function()
n.check_close()
end)
local server1 = new_pipename()
local screen1 = tt.setup_child_nvim({ '--listen', server1, '--clean' })
screen1:expect({ any = vim.pesc('[No Name]') })
@@ -526,11 +551,6 @@ describe('TUI :connect', function()
end)
it('! stops the current server', function()
n.clear()
finally(function()
n.check_close()
end)
local server1 = new_pipename()
local screen1 = tt.setup_child_nvim({ '--listen', server1, '--clean' })
screen1:expect({ any = vim.pesc('[No Name]') })