mirror of
https://github.com/neovim/neovim.git
synced 2026-07-17 14:41:33 +00:00
fix(restart): keep :restart error message concise #40746
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
-- For "--listen", ":restart", and related remote/server functionality.
|
||||
|
||||
local util = require('vim._core.util')
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Called by builtin serverlist(). Returns the combined server list (own + peers).
|
||||
@@ -204,8 +206,16 @@ function M.ex_session_restart(eap, extra)
|
||||
end)
|
||||
|
||||
if not success then
|
||||
--- @cast msg string
|
||||
vim.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
|
||||
util.echo_err(trimmed_msg:sub(5))
|
||||
else
|
||||
error(msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -528,16 +528,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') })
|
||||
@@ -575,11 +577,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