feat(messages): "verbose" message kind #31991

This commit is contained in:
luukvbaal
2025-01-13 13:59:34 +01:00
committed by GitHub
parent 47866cd8d2
commit cb7b4e2962
4 changed files with 68 additions and 9 deletions

View File

@ -96,7 +96,7 @@ EVENTS
• `msg_show`:
• `history` argument indicating if the message was added to the history.
• new message kinds: "bufwrite", "completion", "list_cmd", "lua_print",
"search_cmd", "undo", "wildlist".
"search_cmd", "undo", "verbose", wildlist".
HIGHLIGHTS

View File

@ -806,6 +806,7 @@ must handle.
"search_cmd" Entered search command
"search_count" Search count message ("S" flag of 'shortmess')
"undo" |:undo| and |:redo| message
"verbose" 'verbose' message
"wildlist" 'wildmode' "list" message
"wmsg" Warning ("search hit BOTTOM", |W10|, …)
New kinds may be added in the future; clients should treat unknown

View File

@ -3324,6 +3324,10 @@ int redirecting(void)
|| redir_reg || redir_vname || capture_ga != NULL;
}
// Save and restore message kind when emitting a verbose message.
static const char *pre_verbose_kind = NULL;
static const char *verbose_kind = "verbose";
/// Before giving verbose message.
/// Must always be called paired with verbose_leave()!
void verbose_enter(void)
@ -3331,6 +3335,10 @@ void verbose_enter(void)
if (*p_vfile != NUL) {
msg_silent++;
}
if (msg_ext_kind != verbose_kind) {
pre_verbose_kind = msg_ext_kind;
msg_ext_set_kind("verbose");
}
}
/// After giving verbose message.
@ -3342,14 +3350,17 @@ void verbose_leave(void)
msg_silent = 0;
}
}
if (pre_verbose_kind != NULL) {
msg_ext_set_kind(pre_verbose_kind);
pre_verbose_kind = NULL;
}
}
/// Like verbose_enter() and set msg_scroll when displaying the message.
void verbose_enter_scroll(void)
{
if (*p_vfile != NUL) {
msg_silent++;
} else {
verbose_enter();
if (*p_vfile == NUL) {
// always scroll up, don't overwrite
msg_scroll = true;
}
@ -3358,11 +3369,8 @@ void verbose_enter_scroll(void)
/// Like verbose_leave() and set cmdline_row when displaying the message.
void verbose_leave_scroll(void)
{
if (*p_vfile != NUL) {
if (--msg_silent < 0) {
msg_silent = 0;
}
} else {
verbose_leave();
if (*p_vfile == NUL) {
cmdline_row = msg_row;
}
}

View File

@ -330,6 +330,56 @@ describe('ui/ext_messages', function()
},
},
})
feed(':1verbose filter Diff[AC] hi<CR>')
screen:expect({
cmdline = { {
abort = false,
} },
messages = {
{
content = {
{ '\nDiffAdd ' },
{ 'xxx', 22, 30 },
{ ' ' },
{ 'ctermbg=', 18, 5 },
{ '81 ' },
{ 'guibg=', 18, 5 },
{ 'LightBlue' },
},
history = false,
kind = 'list_cmd',
},
{
content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
history = false,
kind = 'verbose',
},
{
content = {
{ '\nDiffChange ' },
{ 'xxx', 4, 31 },
{ ' ' },
{ 'ctermbg=', 18, 5 },
{ '225 ' },
{ 'guibg=', 18, 5 },
{ 'LightMagenta' },
},
history = false,
kind = 'list_cmd',
},
{
content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
history = false,
kind = 'verbose',
},
{
content = { { 'Press ENTER or type command to continue', 6, 18 } },
history = false,
kind = 'return_prompt',
},
},
})
end)
it(':echoerr', function()