mirror of
https://github.com/neovim/neovim.git
synced 2026-08-02 13:49:19 +00:00
fix(restart): keep :restart error message concise #40746
(cherry picked from commit 4f1ef2dec1)
This commit is contained in:
@@ -149,8 +149,16 @@ function M.ex_session_restart(after_cmd, quit_cmd)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
--- @cast msg string
|
||||
fs.rm(session, { force = true })
|
||||
error(msg)
|
||||
|
||||
-- Trim error message to be equivalent to `:restart!`
|
||||
local trimmed_msg = msg:match('Vim:.*$')
|
||||
if trimmed_msg then
|
||||
vim.api.nvim_echo({ { trimmed_msg:sub(5) } }, true, { err = true })
|
||||
else
|
||||
error(msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -520,16 +520,18 @@ describe('TUI :restart', function()
|
||||
assert_exitreason()
|
||||
assert_termguicolors_and_no_gui_running()
|
||||
|
||||
-- Check ":restart! +echo" cannot restart server.
|
||||
-- Check ":restart[!] +echo" cannot restart server.
|
||||
-- Check the full screen state to ensure this doesn't pollute the current UI.
|
||||
tt.feed_data(':restart! +echo\013')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~}{18: }|*3
|
||||
{3:[No Name] }|
|
||||
{9:restart failed: +cmd did not quit the server} |
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
for _, cmd in ipairs({ ':restart', ':restart!' }) do
|
||||
tt.feed_data(cmd .. ' +echo\013')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~}{18: }|*3
|
||||
{3:[No Name] }|
|
||||
{9:restart failed: +cmd did not quit the server} |
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
end
|
||||
|
||||
tt.feed_data('ithis will be removed\027')
|
||||
screen:expect({ any = vim.pesc('this will be remove^d') })
|
||||
@@ -567,11 +569,13 @@ describe('TUI :restart', function()
|
||||
tt.feed_data(':confirm restart! +echo\013')
|
||||
screen:expect({ any = vim.pesc('+cmd did not quit the server') })
|
||||
|
||||
-- Check ":restart!" on a modified buffer.
|
||||
-- Check ":restart[!]" on a modified buffer.
|
||||
tt.feed_data('ithis will be removed\027')
|
||||
tt.feed_data(':restart!\013')
|
||||
screen:expect({ any = vim.pesc('Vim(qall):E37: No write since last change') })
|
||||
assert_exitreason('QuitPre:restart\nExitPre:restart\n')
|
||||
for _, cmd in ipairs({ ':restart', ':restart!' }) do
|
||||
tt.feed_data(cmd .. '\013')
|
||||
screen:expect({ any = vim.pesc('Vim(qall):E37: No write since last change') })
|
||||
assert_exitreason('QuitPre:restart\nExitPre:restart\n')
|
||||
end
|
||||
|
||||
-- Check ":restart! +qall!" on a modified buffer.
|
||||
tt.feed_data('ithis will be removed\027')
|
||||
|
||||
Reference in New Issue
Block a user