fix(messages): improve deadly signal messages #32364

Problem:
Deadly signal messages mention "Vim", and add redundant newlines.

Solution:
- Update the messages.
- Don't add an extra newline.
This commit is contained in:
Justin M. Keyes
2025-02-07 05:49:52 -08:00
committed by GitHub
parent 52ff5e3032
commit ad853d1df0
3 changed files with 13 additions and 14 deletions

View File

@ -845,8 +845,9 @@ void preserve_exit(const char *errmsg)
// For TUI: exit alternate screen so that the error messages can be seen. // For TUI: exit alternate screen so that the error messages can be seen.
ui_client_stop(); ui_client_stop();
} }
if (errmsg != NULL) { if (errmsg != NULL && errmsg[0] != NUL) {
fprintf(stderr, "%s\n", errmsg); size_t has_eol = '\n' == errmsg[strlen(errmsg) - 1];
fprintf(stderr, has_eol ? "%s" : "%s\n", errmsg);
} }
if (ui_client_channel_id) { if (ui_client_channel_id) {
os_exit(1); os_exit(1);
@ -857,7 +858,7 @@ void preserve_exit(const char *errmsg)
FOR_ALL_BUFFERS(buf) { FOR_ALL_BUFFERS(buf) {
if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) { if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) {
if (errmsg != NULL) { if (errmsg != NULL) {
fprintf(stderr, "Vim: preserving files...\r\n"); fprintf(stderr, "Nvim: preserving files...\n");
} }
ml_sync_all(false, false, true); // preserve all swap files ml_sync_all(false, false, true); // preserve all swap files
break; break;
@ -867,7 +868,7 @@ void preserve_exit(const char *errmsg)
ml_close_all(false); // close all memfiles, without deleting ml_close_all(false); // close all memfiles, without deleting
if (errmsg != NULL) { if (errmsg != NULL) {
fprintf(stderr, "Vim: Finished.\r\n"); fprintf(stderr, "Nvim: Finished.\n");
} }
getout(1); getout(1);

View File

@ -175,7 +175,7 @@ static void deadly_signal(int signum)
ILOG("got signal %d (%s)", signum, signal_name(signum)); ILOG("got signal %d (%s)", signum, signal_name(signum));
snprintf(IObuff, IOSIZE, "Vim: Caught deadly signal '%s'\r\n", signal_name(signum)); snprintf(IObuff, IOSIZE, "Nvim: Caught deadly signal '%s'\n", signal_name(signum));
// Preserve files and exit. // Preserve files and exit.
preserve_exit(IObuff); preserve_exit(IObuff);

View File

@ -1951,10 +1951,10 @@ describe('TUI', function()
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]]) exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
screen:expect { screen:expect {
grid = [[ grid = [[
Vim: Caught deadly signal 'SIGTERM' | Nvim: Caught deadly signal 'SIGTERM' |
|*2 |
[Process exited 1]^ | [Process exited 1]^ |
|*2 |*3
{3:-- TERMINAL --} | {3:-- TERMINAL --} |
]], ]],
} }
@ -3337,9 +3337,7 @@ describe('TUI bg color', function()
end) end)
end) end)
-- These tests require `tt` because --headless/--embed describe('TUI client', function()
-- does not initialize the TUI.
describe('TUI as a client', function()
after_each(function() after_each(function()
os.remove(testlog) os.remove(testlog)
end) end)
@ -3449,10 +3447,10 @@ describe('TUI as a client', function()
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]]) exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
screen_client:expect { screen_client:expect {
grid = [[ grid = [[
Vim: Caught deadly signal 'SIGTERM' | Nvim: Caught deadly signal 'SIGTERM' |
|*2 |
[Process exited 1]^ | [Process exited 1]^ |
|*2 |*3
{3:-- TERMINAL --} | {3:-- TERMINAL --} |
]], ]],
} }