vim-patch:9.1.0864: message history is fixed to 200 (#31215)

Problem:  message history is fixed to 200
Solution: Add the 'msghistory' option, increase the default
          value to 500 (Shougo Matsushita)

closes: vim/vim#16048

4bd9b2b246

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Co-authored-by: Milly <milly.ca@gmail.com>
This commit is contained in:
zeertzjq 2024-11-15 08:04:49 +08:00 committed by GitHub
parent 05d354e216
commit fa0dcde3d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 49 additions and 5 deletions

View File

@ -228,6 +228,7 @@ LUA
OPTIONS OPTIONS
• 'completeopt' flag "fuzzy" enables |fuzzy-matching| during |ins-completion|. • 'completeopt' flag "fuzzy" enables |fuzzy-matching| during |ins-completion|.
• 'msghistory' controls maximum number of messages to remember.
• 'tabclose' controls which tab page to focus when closing a tab page. • 'tabclose' controls which tab page to focus when closing a tab page.
PERFORMANCE PERFORMANCE

View File

@ -3197,7 +3197,8 @@ A jump table for the options with a short description can be found at |Q_op|.
global global
A history of ":" commands, and a history of previous search patterns A history of ":" commands, and a history of previous search patterns
is remembered. This option decides how many entries may be stored in is remembered. This option decides how many entries may be stored in
each of these histories (see |cmdline-editing|). each of these histories (see |cmdline-editing| and 'msghistory' for
the number of messages to remember).
The maximum value is 10000. The maximum value is 10000.
*'hlsearch'* *'hls'* *'nohlsearch'* *'nohls'* *'hlsearch'* *'hls'* *'nohlsearch'* *'nohls'*
@ -4289,6 +4290,12 @@ A jump table for the options with a short description can be found at |Q_op|.
Defines the maximum time in msec between two mouse clicks for the Defines the maximum time in msec between two mouse clicks for the
second click to be recognized as a multi click. second click to be recognized as a multi click.
*'msghistory'* *'mhi'*
'msghistory' 'mhi' number (default 500)
global
Determines how many entries are remembered in the |:messages| history.
The maximum value is 10000.
*'nrformats'* *'nf'* *'nrformats'* *'nf'*
'nrformats' 'nf' string (default "bin,hex") 'nrformats' 'nf' string (default "bin,hex")
local to buffer local to buffer

View File

@ -3016,7 +3016,8 @@ vim.go.hid = vim.go.hidden
--- A history of ":" commands, and a history of previous search patterns --- A history of ":" commands, and a history of previous search patterns
--- is remembered. This option decides how many entries may be stored in --- is remembered. This option decides how many entries may be stored in
--- each of these histories (see `cmdline-editing`). --- each of these histories (see `cmdline-editing` and 'msghistory' for
--- the number of messages to remember).
--- The maximum value is 10000. --- The maximum value is 10000.
--- ---
--- @type integer --- @type integer
@ -4378,6 +4379,15 @@ vim.o.mouset = vim.o.mousetime
vim.go.mousetime = vim.o.mousetime vim.go.mousetime = vim.o.mousetime
vim.go.mouset = vim.go.mousetime vim.go.mouset = vim.go.mousetime
--- Determines how many entries are remembered in the `:messages` history.
--- The maximum value is 10000.
---
--- @type integer
vim.o.msghistory = 500
vim.o.mhi = vim.o.msghistory
vim.go.msghistory = vim.o.msghistory
vim.go.mhi = vim.go.msghistory
--- This defines what bases Vim will consider for numbers when using the --- This defines what bases Vim will consider for numbers when using the
--- CTRL-A and CTRL-X commands for adding to and subtracting from a number --- CTRL-A and CTRL-X commands for adding to and subtracting from a number
--- respectively; see `CTRL-A` for more info on these commands. --- respectively; see `CTRL-A` for more info on these commands.

View File

@ -626,6 +626,8 @@ call <SID>AddOption("terse", gettext("add 's' flag in 'shortmess' (don't show se
call <SID>BinOptionG("terse", &terse) call <SID>BinOptionG("terse", &terse)
call <SID>AddOption("shortmess", gettext("list of flags to make messages shorter")) call <SID>AddOption("shortmess", gettext("list of flags to make messages shorter"))
call <SID>OptionG("shm", &shm) call <SID>OptionG("shm", &shm)
call <SID>AddOption("msghistory", gettext("how many messages are remembered"))
call append("$", " \tset mhi=" . &mhi)
call <SID>AddOption("showcmd", gettext("show (partial) command keys in location given by 'showcmdloc'")) call <SID>AddOption("showcmd", gettext("show (partial) command keys in location given by 'showcmdloc'"))
let &sc = s:old_sc let &sc = s:old_sc
call <SID>BinOptionG("sc", &sc) call <SID>BinOptionG("sc", &sc)

View File

@ -981,7 +981,7 @@ static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multili
} }
// Don't let the message history get too big // Don't let the message history get too big
while (msg_hist_len > MAX_MSG_HIST_LEN) { while (msg_hist_len > p_mhi) {
delete_first_msg(); delete_first_msg();
} }

View File

@ -2874,6 +2874,13 @@ static const char *validate_num_option(OptIndex opt_idx, OptInt *newval, char *e
return e_invarg; return e_invarg;
} }
break; break;
case kOptMsghistory:
if (value < 0) {
return e_positive;
} else if (value > 10000) {
return e_invarg;
}
break;
case kOptPyxversion: case kOptPyxversion:
if (value == 0) { if (value == 0) {
*newval = 3; *newval = 3;

View File

@ -536,6 +536,7 @@ EXTERN OptInt p_mousescroll_vert INIT( = MOUSESCROLL_VERT_DFLT);
EXTERN OptInt p_mousescroll_hor INIT( = MOUSESCROLL_HOR_DFLT); EXTERN OptInt p_mousescroll_hor INIT( = MOUSESCROLL_HOR_DFLT);
EXTERN OptInt p_mouset; ///< 'mousetime' EXTERN OptInt p_mouset; ///< 'mousetime'
EXTERN int p_more; ///< 'more' EXTERN int p_more; ///< 'more'
EXTERN OptInt p_mhi; ///< 'msghistory'
EXTERN char *p_nf; ///< 'nrformats' EXTERN char *p_nf; ///< 'nrformats'
EXTERN char *p_opfunc; ///< 'operatorfunc' EXTERN char *p_opfunc; ///< 'operatorfunc'
EXTERN char *p_para; ///< 'paragraphs' EXTERN char *p_para; ///< 'paragraphs'

View File

@ -3962,7 +3962,8 @@ return {
desc = [=[ desc = [=[
A history of ":" commands, and a history of previous search patterns A history of ":" commands, and a history of previous search patterns
is remembered. This option decides how many entries may be stored in is remembered. This option decides how many entries may be stored in
each of these histories (see |cmdline-editing|). each of these histories (see |cmdline-editing| and 'msghistory' for
the number of messages to remember).
The maximum value is 10000. The maximum value is 10000.
]=], ]=],
full_name = 'history', full_name = 'history',
@ -5757,6 +5758,19 @@ return {
type = 'number', type = 'number',
varname = 'p_mouset', varname = 'p_mouset',
}, },
{
abbreviation = 'mhi',
defaults = { if_true = 500 },
desc = [=[
Determines how many entries are remembered in the |:messages| history.
The maximum value is 10000.
]=],
full_name = 'msghistory',
scope = { 'global' },
short_desc = N_('how many messages are remembered'),
type = 'number',
varname = 'p_mhi',
},
{ {
abbreviation = 'nf', abbreviation = 'nf',
cb = 'did_set_nrformats', cb = 'did_set_nrformats',

View File

@ -2,7 +2,6 @@
// Some defines from the old feature.h // Some defines from the old feature.h
#define SESSION_FILE "Session.vim" #define SESSION_FILE "Session.vim"
#define MAX_MSG_HIST_LEN 200
#define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" #define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
#define RUNTIME_DIRNAME "runtime" #define RUNTIME_DIRNAME "runtime"

View File

@ -117,6 +117,7 @@ let test_values = {
"\ 'imstyle': [[0, 1], [-1, 2, 999]], "\ 'imstyle': [[0, 1], [-1, 2, 999]],
\ 'lines': [[2, 24, 1000], [-1, 0, 1]], \ 'lines': [[2, 24, 1000], [-1, 0, 1]],
\ 'linespace': [[-1, 0, 2, 4, 999], ['']], \ 'linespace': [[-1, 0, 2, 4, 999], ['']],
\ 'msghistory': [[0, 1, 100, 10000], [-1, 10001]],
\ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]], \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
\ 'regexpengine': [[0, 1, 2], [-1, 3, 999]], \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
\ 'report': [[0, 1, 2, 9999], [-1]], \ 'report': [[0, 1, 2, 9999], [-1]],

View File

@ -743,6 +743,7 @@ func Test_set_option_errors()
call assert_fails('set backupcopy=', 'E474:') call assert_fails('set backupcopy=', 'E474:')
call assert_fails('set regexpengine=3', 'E474:') call assert_fails('set regexpengine=3', 'E474:')
call assert_fails('set history=10001', 'E474:') call assert_fails('set history=10001', 'E474:')
call assert_fails('set msghistory=10001', 'E474:')
call assert_fails('set numberwidth=21', 'E474:') call assert_fails('set numberwidth=21', 'E474:')
call assert_fails('set colorcolumn=-a', 'E474:') call assert_fails('set colorcolumn=-a', 'E474:')
call assert_fails('set colorcolumn=a', 'E474:') call assert_fails('set colorcolumn=a', 'E474:')
@ -756,6 +757,7 @@ func Test_set_option_errors()
endif endif
call assert_fails('set helpheight=-1', 'E487:') call assert_fails('set helpheight=-1', 'E487:')
call assert_fails('set history=-1', 'E487:') call assert_fails('set history=-1', 'E487:')
call assert_fails('set msghistory=-1', 'E487:')
call assert_fails('set report=-1', 'E487:') call assert_fails('set report=-1', 'E487:')
call assert_fails('set shiftwidth=-1', 'E487:') call assert_fails('set shiftwidth=-1', 'E487:')
call assert_fails('set sidescroll=-1', 'E487:') call assert_fails('set sidescroll=-1', 'E487:')