mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 23:31:51 +00:00
vim-patch:9.1.0883: message history cleanup is missing some tests (#31331)
Problem: message history cleanup is missing some tests
Solution: Add tests, refactor common code into did_set_msghistory()
(Shougo Matsushita)
closes: vim/vim#16078
9f860a14c3
Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Co-authored-by: Milly <milly.ca@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user