aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-04 20:14:31 +0800
committerGitHub <noreply@github.com>2023-02-04 20:14:31 +0800
commit69bb145cea56067e6e82ed0a130a51c0d611e540 (patch)
treecbb045aac106e922647bd2a24ea4dd7a4b1763d4 /src/nvim/os
parent90333b24c3582cb017d823583d4896c8bbb8edb8 (diff)
downloadrneovim-69bb145cea56067e6e82ed0a130a51c0d611e540.tar.gz
rneovim-69bb145cea56067e6e82ed0a130a51c0d611e540.tar.bz2
rneovim-69bb145cea56067e6e82ed0a130a51c0d611e540.zip
refactor(exit): pass error message to preserve_exit() (#22097)
Problem: 1. Some calls to preserve_exit() don't put a message in IObuff, so the IObuff printed by preserve_exit() contains unrelated information. 2. If a TUI client runs out of memory or receives a deadly signal, the error message is shown on alternate screen and cannot be easily seen because the TUI exits alternate screen soon afterwards. Solution: Pass error message to preserve_exit() and exit alternate screen before printing it. Note that this doesn't fix the problem that server error messages cannot be easily seen on exit. This is tracked in #21608 and #21843.
Diffstat (limited to 'src/nvim/os')
-rw-r--r--src/nvim/os/input.c3
-rw-r--r--src/nvim/os/signal.c5
2 files changed, 3 insertions, 5 deletions
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 759b3cf83c..44ad0315a5 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -550,8 +550,7 @@ static void read_error_exit(void)
if (silent_mode) { // Normal way to exit for "nvim -es".
getout(0);
}
- STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
- preserve_exit();
+ preserve_exit(_("Vim: Error reading input, exiting...\n"));
}
static bool pending_events(MultiQueue *events)
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index b8daaabba2..e7b745fb7e 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -172,11 +172,10 @@ static void deadly_signal(int signum)
ILOG("got signal %d (%s)", signum, signal_name(signum));
- snprintf(IObuff, sizeof(IObuff), "Vim: Caught deadly signal '%s'\r\n",
- signal_name(signum));
+ snprintf(IObuff, IOSIZE, "Vim: Caught deadly signal '%s'\r\n", signal_name(signum));
// Preserve files and exit.
- preserve_exit();
+ preserve_exit(IObuff);
}
static void on_signal(SignalWatcher *handle, int signum, void *data)