diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 46c143062a..132ddfa8f4 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -456,7 +456,7 @@ void augroup_del(char *name, bool stupid_legacy_mode) for (size_t i = 0; i < kv_size(*acs); i++) { AutoPat *const ap = kv_A(*acs, i).pat; if (ap != NULL && ap->group == group) { - give_warning(_("W19: Deleting augroup that is still in use"), true); + give_warning(_("W19: Deleting augroup that is still in use"), true, true); map_put(String, int)(&map_augroup_name_to_id, cstr_as_string(name), AUGROUP_DELETED); augroup_map_del(ap->group, NULL); return; diff --git a/src/nvim/message.c b/src/nvim/message.c index 0815a99c1e..4e4242a747 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -3526,7 +3526,7 @@ int verbose_open(void) /// Give a warning message (for searching). /// Use 'w' highlighting and may repeat the message after redrawing -void give_warning(const char *message, bool hl) +void give_warning(const char *message, bool hl, bool hist) FUNC_ATTR_NONNULL_ARG(1) { // Don't do this for ":silent". @@ -3534,6 +3534,9 @@ void give_warning(const char *message, bool hl) return; } + bool save_msg_hist_off = msg_hist_off; + msg_hist_off = !hist; + // Don't want a hit-enter prompt here. no_wait_return++; @@ -3557,6 +3560,7 @@ void give_warning(const char *message, bool hl) msg_col = 0; no_wait_return--; + msg_hist_off = save_msg_hist_off; } /// Shows a warning, with optional highlighting. @@ -3575,7 +3579,7 @@ void swmsg(bool hl, const char *const fmt, ...) vim_vsnprintf(IObuff, IOSIZE, fmt, args); va_end(args); - give_warning(IObuff, hl); + give_warning(IObuff, hl, true); } /// Advance msg cursor to column "col". diff --git a/src/nvim/search.c b/src/nvim/search.c index 8f129bfcf4..3f70e64e51 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -954,7 +954,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, if (!shortmess(SHM_SEARCH) && shortmess(SHM_SEARCHCOUNT) && (options & SEARCH_MSG)) { - give_warning(_(dir == BACKWARD ? top_bot_msg : bot_top_msg), true); + give_warning(_(dir == BACKWARD ? top_bot_msg : bot_top_msg), true, false); } if (extra_arg != NULL) { extra_arg->sa_wrapped = true; @@ -1482,7 +1482,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char *pat) if (p_ws) { pos->lnum = buf->b_ml.ml_line_count; if (!shortmess(SHM_SEARCH)) { - give_warning(_(top_bot_msg), true); + give_warning(_(top_bot_msg), true, false); } } else { pos->lnum = 1; @@ -1492,7 +1492,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char *pat) if (p_ws) { pos->lnum = 1; if (!shortmess(SHM_SEARCH)) { - give_warning(_(bot_top_msg), true); + give_warning(_(bot_top_msg), true, false); } } else { pos->lnum = 1; @@ -2674,11 +2674,9 @@ static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, bool sh } // keep the message even after redraw, but don't put in history - msg_hist_off = true; msg_ext_overwrite = true; msg_ext_set_kind("search_count"); - give_warning(msgbuf, false); - msg_hist_off = false; + give_warning(msgbuf, false, false); } // Add the search count information to "stat". diff --git a/src/nvim/spell.c b/src/nvim/spell.c index c193f107a2..8e645f5fd9 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1486,7 +1486,7 @@ size_t spell_move_to(win_T *wp, int dir, smt_T behaviour, bool curline, hlf_T *a lnum = wp->w_buffer->b_ml.ml_line_count; wrapped = true; if (!shortmess(SHM_SEARCH)) { - give_warning(_(top_bot_msg), true); + give_warning(_(top_bot_msg), true, false); } } capcol = -1; @@ -1501,7 +1501,7 @@ size_t spell_move_to(win_T *wp, int dir, smt_T behaviour, bool curline, hlf_T *a lnum = 1; wrapped = true; if (!shortmess(SHM_SEARCH)) { - give_warning(_(bot_top_msg), true); + give_warning(_(bot_top_msg), true, false); } } diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 987d48c74a..e3a6f87335 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -737,7 +737,7 @@ void do_tag(char *tag, int type, int count, int forceit, bool verbose) msg(IObuff, ic ? HLF_W : 0); msg_scroll = true; // Don't overwrite this message. } else { - give_warning(IObuff, ic); + give_warning(IObuff, ic, true); } if (ic && !msg_scrolled && msg_silent == 0 && !ui_has(kUIMessages)) { ui_flush(); diff --git a/src/nvim/undo.c b/src/nvim/undo.c index db8e8fe030..bf02102c0e 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1447,7 +1447,7 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT if (name == NULL) { verbose_enter(); } - give_warning(_("File contents changed, cannot use undo info"), true); + give_warning(_("File contents changed, cannot use undo info"), true, true); if (name == NULL) { verbose_leave(); } diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 4ad8eab359..d556621d56 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -117,7 +117,6 @@ describe('ui/ext_messages', function() { content = { { '/i ' } }, kind = 'search_cmd' }, { content = { { 'search hit BOTTOM, continuing at TOP', 19, 'WarningMsg' } }, - history = true, kind = 'wmsg', }, },