diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index f99e685bd2..4542848bbe 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -376,9 +376,11 @@ OPTIONS • |g:clipboard| accepts a string name to force any builtin clipboard tool. • 'busy' sets a buffer "busy" status. Indicated in the default statusline. • 'pumborder' adds a border to the popup menu. -• |g:clipboard| autodetection only selects tmux when running inside tmux +• |g:clipboard| autodetection only selects tmux when running inside tmux. • 'statusline' allows "stacking" highlight groups (groups inherit from previous highlight attributes) +• 'messagesopt' added progress:c to control if progress messages are shown in + cmdline. PERFORMANCE diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 995229519b..601ce8f63a 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -4364,7 +4364,7 @@ A jump table for the options with a short description can be found at |Q_op|. option has no direct effect, the menu must be refreshed first. *'messagesopt'* *'mopt'* -'messagesopt' 'mopt' string (default "hit-enter,history:500") +'messagesopt' 'mopt' string (default "hit-enter,history:500,progress:c") global Option settings for outputting messages. It can consist of the following items. Items must be separated by a comma. @@ -4384,6 +4384,11 @@ A jump table for the options with a short description can be found at |Q_op|. |:messages| history. The maximum value is 10000. Setting it to zero clears the message history. This item must always be present. + progress:{s} + Determines where to show progress messages. + Valid values are: + empty: progress messages are hidden in cmdline. + "c": progress messages are shown in cmdline. *'mkspellmem'* *'msm'* 'mkspellmem' 'msm' string (default "460000,2000,500") diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index d8e959acb6..f3c9e9158f 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -427,6 +427,8 @@ Options: - 'winblend' pseudo-transparency in floating windows |api-floatwin| - 'winhighlight' window-local highlights - 'busy' busy status for buffers +- 'messagesopt' added progress:c to control if progress messages are shown in + cmdline Performance: - Signs are implemented using Nvim's internal "marktree" (btree) structure. diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index e3989b243b..9b29d3380d 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -4458,9 +4458,14 @@ vim.go.mis = vim.go.menuitems --- `:messages` history. The maximum value is 10000. --- Setting it to zero clears the message history. --- This item must always be present. +--- progress:{s} +--- Determines where to show progress messages. +--- Valid values are: +--- empty: progress messages are hidden in cmdline. +--- "c": progress messages are shown in cmdline. --- --- @type string -vim.o.messagesopt = "hit-enter,history:500" +vim.o.messagesopt = "hit-enter,history:500,progress:c" vim.o.mopt = vim.o.messagesopt vim.go.messagesopt = vim.o.messagesopt vim.go.mopt = vim.go.messagesopt diff --git a/src/nvim/message.c b/src/nvim/message.c index 13c31a6137..7b9e3dcb00 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -106,10 +106,14 @@ static int msg_hist_max = 500; // The default max value is 500 #define MESSAGES_OPT_HIT_ENTER "hit-enter" #define MESSAGES_OPT_WAIT "wait:" #define MESSAGES_OPT_HISTORY "history:" +#define MESSAGES_OPT_PROGRESS "progress:" -// The default is "hit-enter,history:500" -static int msg_flags = kOptMoptFlagHitEnter | kOptMoptFlagHistory; +#define PROGRESS_TARGET_CMD 0x01 + +// The default is "hit-enter,history:500,progress:c" +static int msg_flags = kOptMoptFlagHitEnter | kOptMoptFlagHistory | kOptMoptFlagProgress; static int msg_wait = 0; +static int progress_msg_target = PROGRESS_TARGET_CMD; static FILE *verbose_fd = NULL; static bool verbose_did_open = false; @@ -352,6 +356,20 @@ static HlMessage format_progress_message(HlMessage hl_msg, MessageData *msg_data MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bool err, MessageData *msg_data, bool *needs_msg_clear) { + // provide a new id if not given + if (id.type == kObjectTypeNil) { + id = INTEGER_OBJ(msg_id_next++); + } else if (id.type == kObjectTypeInteger) { + id = id.data.integer > 0 ? id : INTEGER_OBJ(msg_id_next++); + msg_id_next = MAX(msg_id_next, id.data.integer + 1); + } + + // don't display progress message in cmd when target doesn't have cmd + if (strequal(kind, "progress") && (progress_msg_target & PROGRESS_TARGET_CMD) == 0) { + *needs_msg_clear = true; + return id; + } + no_wait_return++; msg_start(); msg_clr_eos(); @@ -362,14 +380,6 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo msg_ext_set_kind(kind); } msg_ext_skip_flush = true; - - // provide a new id if not given - if (id.type == kObjectTypeNil) { - id = INTEGER_OBJ(msg_id_next++); - } else if (id.type == kObjectTypeInteger) { - id = id.data.integer > 0 ? id : INTEGER_OBJ(msg_id_next++); - msg_id_next = MAX(msg_id_next, id.data.integer + 1); - } msg_ext_id = id; // progress message are special displayed as "title: percent% msg" @@ -1224,6 +1234,7 @@ int messagesopt_changed(void) int messages_flags_new = 0; int messages_wait_new = 0; int messages_history_new = 0; + int progress_target_flag = 0; char *p = p_mopt; while (*p != NUL) { @@ -1240,6 +1251,13 @@ int messagesopt_changed(void) p += STRLEN_LITERAL(MESSAGES_OPT_HISTORY); messages_history_new = getdigits_int(&p, false, INT_MAX); messages_flags_new |= kOptMoptFlagHistory; + } else if (strnequal(p, S_LEN(MESSAGES_OPT_PROGRESS))) { + p += STRLEN_LITERAL(MESSAGES_OPT_PROGRESS); + messages_flags_new |= kOptMoptFlagProgress; + if (*p == 'c') { + progress_target_flag |= PROGRESS_TARGET_CMD; + p++; + } } if (*p != ',' && *p != NUL) { @@ -1274,6 +1292,7 @@ int messagesopt_changed(void) msg_flags = messages_flags_new; msg_wait = messages_wait_new; + progress_msg_target = progress_target_flag; msg_hist_max = messages_history_new; msg_hist_clear(msg_hist_max); diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 461083dc28..4e224ab92e 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -5774,8 +5774,8 @@ local options = { { abbreviation = 'mopt', cb = 'did_set_messagesopt', - defaults = 'hit-enter,history:500', - values = { 'hit-enter', 'wait:', 'history:' }, + defaults = 'hit-enter,history:500,progress:c', + values = { 'hit-enter', 'wait:', 'history:', 'progress:' }, flags = true, deny_duplicates = true, desc = [=[ @@ -5797,6 +5797,11 @@ local options = { |:messages| history. The maximum value is 10000. Setting it to zero clears the message history. This item must always be present. + progress:{s} + Determines where to show progress messages. + Valid values are: + empty: progress messages are hidden in cmdline. + "c": progress messages are shown in cmdline. ]=], full_name = 'messagesopt', list = 'onecommacolon', diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 223088b3e8..2b8e54b2a6 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -3805,4 +3805,61 @@ describe('progress-message', function() data = {}, }, 'progress autocmd receives progress messages') end) + + it('can be hidden from cmdline with messagesopt-=progress:c', function() + exec('set messagesopt-=progress:c') + api.nvim_echo( + { { 'test-message: not shown in cmdline' } }, + true, + { kind = 'progress', title = 'TestSuite', percent = 10, status = 'running' } + ) + screen:expect([[ + ^ | + {1:~ }|*4 + ]]) + + assert_progress_autocmd({ + text = { 'test-message: not shown in cmdline' }, + percent = 10, + status = 'running', + title = 'TestSuite', + id = 1, + data = {}, + }, 'progress autocmd still receives progress even with progress messages hidden from cmd') + + exec('set messagesopt+=progress:c') + api.nvim_echo( + { { 'test-message: shown in cmdline' } }, + true, + { kind = 'progress', title = 'TestSuite', percent = 10, status = 'running' } + ) + screen:expect({ + grid = [[ + ^ | + {1:~ }|*4 + ]], + messages = { + { + content = { + { 'TestSuite', 6, 'MoreMsg' }, + { ': ' }, + { ' 10% ', 19, 'WarningMsg' }, + { 'test-message: shown in cmdline' }, + }, + history = true, + id = 2, + kind = 'progress', + }, + }, + }) + + assert_progress_autocmd({ + text = { 'test-message: shown in cmdline' }, + percent = 10, + status = 'running', + title = 'TestSuite', + id = 2, + data = {}, + }, 'progress autocmd still receives progresswith progress messages shown in cmd') + end) end) diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim index 3b8c0ef6ff..07997a5ee5 100644 --- a/test/old/testdir/gen_opt_test.vim +++ b/test/old/testdir/gen_opt_test.vim @@ -286,13 +286,14 @@ let test_values = { \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']], \ 'maxsearchcount': [[1, 10, 100, 1000], [0, -1, 10000]], \ 'messagesopt': [['hit-enter,history:1', 'hit-enter,history:10000', - \ 'history:100,wait:100', 'history:0,wait:0', - \ 'hit-enter,history:1,wait:1'], + \ 'history:100,wait:100', 'history:0,wait:0,progress:', + \ 'hit-enter,history:1,wait:1,progress:c'], \ ['xxx', 'history:500', 'hit-enter,history:-1', \ 'hit-enter,history:10001', 'history:0,wait:10001', \ 'hit-enter', 'history:10,wait:99999999999999999999', \ 'history:99999999999999999999,wait:10', 'wait:10', - \ 'history:-10', 'history:10,wait:-10']], + \ 'history:-10', 'history:10,wait:-10', + \ 'history:0,wait:0,progress:a', 'history:0,wait:0,progress:ca']], \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']], \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'], \ ['xxx', 'n,v,i']], diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim index efc63d24b1..37c80177bc 100644 --- a/test/old/testdir/setup.vim +++ b/test/old/testdir/setup.vim @@ -18,6 +18,7 @@ if exists('s:did_load') set laststatus=1 set listchars=eol:$ set maxsearchcount=99 + set messagesopt=hit-enter,history:500 set mousemodel=extend set nohidden nosmarttab noautoindent noautoread set nohlsearch noincsearch diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim index e83272c525..8e3b799ac4 100644 --- a/test/old/testdir/test_options.vim +++ b/test/old/testdir/test_options.vim @@ -682,7 +682,7 @@ func Test_set_completion_string_values() " call assert_equal("\"set hl=8bi i", @:) " messagesopt - call assert_equal(['history:', 'hit-enter', 'wait:'], + call assert_equal(['history:', 'hit-enter', 'progress:', 'wait:'], \ getcompletion('set messagesopt+=', 'cmdline')->sort()) "