patch 9.1.0883: message history cleanup is missing some tests

Problem:  message history cleanup is missing some tests
Solution: Add tests, refactor common code into did_set_msghistory()
          (Shougo Matsushita)

closes: #16078

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Milly <milly.ca@gmail.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Shougo Matsushita
2024-11-24 13:48:05 +01:00
committed by Christian Brabandt
parent a01148d2cb
commit 9f860a14c3
8 changed files with 69 additions and 16 deletions

View File

@ -3864,6 +3864,31 @@ did_set_number_relativenumber(optset_T *args UNUSED)
return NULL;
}
/*
* Process the updated 'msghistory' option value.
*/
char *
did_set_msghistory(optset_T *args UNUSED)
{
char *errmsg = NULL;
// 'msghistory' must be positive
if (p_mhi < 0)
{
errmsg = e_argument_must_be_positive;
p_mhi = 0;
}
else if (p_mhi > 10000)
{
errmsg = e_invalid_argument;
p_mhi = 10000;
}
check_msg_hist();
return errmsg;
}
#if defined(FEAT_LINEBREAK) || defined(PROTO)
/*
* Process the new 'numberwidth' option value.
@ -4914,16 +4939,6 @@ check_num_option_bounds(
errmsg = e_invalid_argument;
p_hi = 10000;
}
if (p_mhi < 0)
{
errmsg = e_argument_must_be_positive;
p_mhi = 0;
}
else if (p_mhi > 10000)
{
errmsg = e_invalid_argument;
p_mhi = 10000;
}
if (p_re < 0 || p_re > 2)
{
errmsg = e_invalid_argument;