diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 53a13b08cb..c20721224c 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -228,6 +228,7 @@ LUA OPTIONS • '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. PERFORMANCE diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 3217f5c565..c972a05c4d 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3197,7 +3197,8 @@ A jump table for the options with a short description can be found at |Q_op|. global A history of ":" commands, and a history of previous search patterns 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. *'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 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' string (default "bin,hex") local to buffer diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index 45ab14a774..cb783720ac 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -3016,7 +3016,8 @@ vim.go.hid = vim.go.hidden --- A history of ":" commands, and a history of previous search patterns --- 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. --- --- @type integer @@ -4378,6 +4379,15 @@ vim.o.mouset = vim.o.mousetime vim.go.mousetime = vim.o.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 --- CTRL-A and CTRL-X commands for adding to and subtracting from a number --- respectively; see `CTRL-A` for more info on these commands. diff --git a/runtime/optwin.vim b/runtime/optwin.vim index da70ff1afe..48a4bd2816 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -626,6 +626,8 @@ call AddOption("terse", gettext("add 's' flag in 'shortmess' (don't show se call BinOptionG("terse", &terse) call AddOption("shortmess", gettext("list of flags to make messages shorter")) call OptionG("shm", &shm) +call AddOption("msghistory", gettext("how many messages are remembered")) +call append("$", " \tset mhi=" . &mhi) call AddOption("showcmd", gettext("show (partial) command keys in location given by 'showcmdloc'")) let &sc = s:old_sc call BinOptionG("sc", &sc) diff --git a/src/nvim/message.c b/src/nvim/message.c index e8ba2a9aeb..e8f20916b8 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -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 - while (msg_hist_len > MAX_MSG_HIST_LEN) { + while (msg_hist_len > p_mhi) { delete_first_msg(); } diff --git a/src/nvim/option.c b/src/nvim/option.c index 03b7c8cb14..efd52f9233 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2874,6 +2874,13 @@ static const char *validate_num_option(OptIndex opt_idx, OptInt *newval, char *e return e_invarg; } break; + case kOptMsghistory: + if (value < 0) { + return e_positive; + } else if (value > 10000) { + return e_invarg; + } + break; case kOptPyxversion: if (value == 0) { *newval = 3; diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h index a60bd047c1..e0a972f06c 100644 --- a/src/nvim/option_vars.h +++ b/src/nvim/option_vars.h @@ -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_mouset; ///< 'mousetime' EXTERN int p_more; ///< 'more' +EXTERN OptInt p_mhi; ///< 'msghistory' EXTERN char *p_nf; ///< 'nrformats' EXTERN char *p_opfunc; ///< 'operatorfunc' EXTERN char *p_para; ///< 'paragraphs' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index e648d4350a..6fab0621f9 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -3962,7 +3962,8 @@ return { desc = [=[ A history of ":" commands, and a history of previous search patterns 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. ]=], full_name = 'history', @@ -5757,6 +5758,19 @@ return { type = 'number', 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', cb = 'did_set_nrformats', diff --git a/src/nvim/vim_defs.h b/src/nvim/vim_defs.h index f6b348e009..72aaa77533 100644 --- a/src/nvim/vim_defs.h +++ b/src/nvim/vim_defs.h @@ -2,7 +2,6 @@ // Some defines from the old feature.h #define SESSION_FILE "Session.vim" -#define MAX_MSG_HIST_LEN 200 #define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" #define RUNTIME_DIRNAME "runtime" diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim index 532ec965d1..be5a7e6ee4 100644 --- a/test/old/testdir/gen_opt_test.vim +++ b/test/old/testdir/gen_opt_test.vim @@ -117,6 +117,7 @@ let test_values = { "\ 'imstyle': [[0, 1], [-1, 2, 999]], \ 'lines': [[2, 24, 1000], [-1, 0, 1]], \ 'linespace': [[-1, 0, 2, 4, 999], ['']], + \ 'msghistory': [[0, 1, 100, 10000], [-1, 10001]], \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]], \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]], \ 'report': [[0, 1, 2, 9999], [-1]], diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim index 540936e7ec..b6bdb1be52 100644 --- a/test/old/testdir/test_options.vim +++ b/test/old/testdir/test_options.vim @@ -743,6 +743,7 @@ func Test_set_option_errors() call assert_fails('set backupcopy=', 'E474:') call assert_fails('set regexpengine=3', '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 colorcolumn=-a', 'E474:') call assert_fails('set colorcolumn=a', 'E474:') @@ -756,6 +757,7 @@ func Test_set_option_errors() endif call assert_fails('set helpheight=-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 shiftwidth=-1', 'E487:') call assert_fails('set sidescroll=-1', 'E487:')