commit 9486e4f2e257cf007708f88a11b92864f90d883a
parent 2eb11f21eb04fbbd7e51afe2bc4453d6f77a0ebd
Author: Justin M. Keyes <justinkz@gmail.com>
Date: Thu, 18 Dec 2025 22:37:58 -0500
refactor(messages): encapsulate msg_delay logic
see also 9bbbeb60e355844780db0aef955e860d68ac0342
Diffstat:
7 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
@@ -1990,8 +1990,7 @@ buf_T *buflist_new(char *ffname_arg, char *sfname_arg, linenr_T lnum, int flags)
pmap_put(int)(&buffer_handles, buf->b_fnum, buf);
if (top_file_num < 0) { // wrap around (may cause duplicates)
emsg(_("W14: Warning: List of file names overflow"));
- if (emsg_silent == 0 && !in_assert_fails && !ui_has(kUIMessages)) {
- ui_flush();
+ if (emsg_silent == 0 && !in_assert_fails) {
msg_delay(3001, true); // make sure it is noticed
}
top_file_num = 1;
diff --git a/src/nvim/change.c b/src/nvim/change.c
@@ -92,8 +92,7 @@ void change_warning(buf_T *buf, int col)
set_vim_var_string(VV_WARNINGMSG, _(w_readonly), -1);
msg_clr_eos();
msg_end();
- if (msg_silent == 0 && !silent_mode && ui_active() && !ui_has(kUIMessages)) {
- ui_flush();
+ if (msg_silent == 0 && !silent_mode && ui_active()) {
msg_delay(1002, true); // give the user time to think about it
}
buf->b_did_warn = true;
@@ -132,7 +131,6 @@ void changed(buf_T *buf)
// message. Since we could be anywhere, call wait_return() now,
// and don't let the emsg() set msg_scroll.
if (need_wait_return && emsg_silent == 0 && !in_assert_fails && !ui_has(kUIMessages)) {
- ui_flush();
msg_delay(2002, true);
wait_return(true);
msg_scroll = save_msg_scroll;
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
@@ -3028,12 +3028,8 @@ int buf_check_timestamp(buf_T *buf)
msg_clr_eos();
msg_end();
if (emsg_silent == 0 && !in_assert_fails && !ui_has(kUIMessages)) {
- ui_flush();
- // give the user some time to think about it
- msg_delay(1004, true);
-
- // don't redraw and erase the message
- redraw_cmdline = false;
+ msg_delay(1004, true); // give the user some time to think about it
+ redraw_cmdline = false; // don't redraw and erase the message
}
}
already_warned = true;
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
@@ -552,10 +552,7 @@ bool check_compl_option(bool dict_opt)
if (emsg_silent == 0 && !in_assert_fails) {
vim_beep(kOptBoFlagComplete);
setcursor();
- if (!ui_has(kUIMessages)) {
- ui_flush();
- msg_delay(2004, false);
- }
+ msg_delay(2004, false);
}
return false;
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
@@ -3923,17 +3923,22 @@ int vim_dialog_yesnoallcancel(int type, char *title, char *message, int dflt)
return VIM_CANCEL;
}
-/// Force the user to see a message by pausing for `ms` milliseconds.
+/// Only for legacy UI (`!ui_has(kUIMessages)`): Pause to display a message for `ms` milliseconds.
///
/// TODO(justinmk): Most of these cases may not be needed after "ui2"...
void msg_delay(uint64_t ms, bool ignoreinput)
{
+ if (ui_has(kUIMessages)) {
+ return;
+ }
+
if (nvim_testing) {
// XXX: Skip non-functional (UI only) delay in tests/CI.
ms = 100;
}
DLOG("%" PRIu64 " ms%s", ms, nvim_testing ? " (skipped by NVIM_TEST)" : "");
+ ui_flush();
os_delay(ms, ignoreinput);
}
@@ -3944,7 +3949,6 @@ void msg_check_for_delay(bool check_msg_scroll)
{
if ((emsg_on_display || (check_msg_scroll && msg_scroll))
&& !did_wait_return && emsg_silent == 0 && !in_assert_fails && !ui_has(kUIMessages)) {
- ui_flush();
msg_delay(1006, true);
emsg_on_display = false;
if (check_msg_scroll) {
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
@@ -701,7 +701,7 @@ static void normal_redraw_mode_message(NormalState *s)
setcursor();
ui_cursor_shape(); // show different cursor shape
ui_flush();
- if (!ui_has(kUIMessages) && (msg_scroll || emsg_on_display)) {
+ if (msg_scroll || emsg_on_display) {
msg_delay(1003, true); // wait at least one second
}
if (ui_has(kUIMessages)) {
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
@@ -742,8 +742,7 @@ void do_tag(char *tag, int type, int count, int forceit, bool verbose)
} else {
give_warning(IObuff, ic, true);
}
- if (ic && !msg_scrolled && msg_silent == 0 && !ui_has(kUIMessages)) {
- ui_flush();
+ if (ic && !msg_scrolled && msg_silent == 0) {
msg_delay(1007, true);
}
}
@@ -2981,8 +2980,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, bool keep_help)
// is set and match found while ignoring case.
if (found == 2 || !save_p_ic) {
msg(_("E435: Couldn't find tag, just guessing!"), 0);
- if (!msg_scrolled && msg_silent == 0 && !ui_has(kUIMessages)) {
- ui_flush();
+ if (!msg_scrolled && msg_silent == 0) {
msg_delay(1010, true);
}
}