diff options
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index c758d5d76f..0b1156a6bd 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -982,11 +982,6 @@ static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multili return; } - // Don't let the message history get too big - while (msg_hist_len > p_mhi) { - delete_first_msg(); - } - // allocate an entry and add the message at the end of the history struct msg_hist *p = xmalloc(sizeof(struct msg_hist)); if (s) { @@ -1018,6 +1013,8 @@ static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multili first_msg_hist = last_msg_hist; } msg_hist_len++; + + check_msg_hist(); } /// Delete the first (oldest) message from the history. @@ -1041,6 +1038,14 @@ int delete_first_msg(void) return OK; } +void check_msg_hist(void) +{ + // Don't let the message history get too big + while (msg_hist_len > 0 && msg_hist_len > p_mhi) { + (void)delete_first_msg(); + } +} + /// :messages command implementation void ex_messages(exarg_T *eap) FUNC_ATTR_NONNULL_ALL |