fix(messages): "list_cmd" kind for :command, :version (#34529)

Problem:  No ext_messages kind for the :command, :version commands.
          :version is emitted as multiple events.
Solution: Assign them the "list_cmd" kind. Use `msg_put*` to properly
          format the message as a single event.
This commit is contained in:
luukvbaal
2025-06-18 07:54:49 +02:00
committed by GitHub
parent 8af2aea24f
commit 3b85046ed5
5 changed files with 49 additions and 6 deletions

View File

@ -448,6 +448,7 @@ static void uc_list(char *name, size_t name_len)
{
bool found = false;
msg_ext_set_kind("list_cmd");
// In cmdwin, the alternative buffer should be used.
const garray_T *gap = &prevwin_curwin()->w_buffer->b_ucmds;
while (true) {

View File

@ -2557,7 +2557,9 @@ void ex_version(exarg_T *eap)
{
// Ignore a ":version 9.99" command.
if (*eap->arg == NUL) {
msg_putchar('\n');
if (!ui_has(kUIMessages)) {
msg_putchar('\n');
}
list_version();
}
}
@ -2671,19 +2673,23 @@ void list_lua_version(void)
(Array)ARRAY_DICT_INIT, kRetObject, NULL, &err);
assert(!ERROR_SET(&err));
assert(ret.type == kObjectTypeString);
msg(ret.data.string.data, 0);
msg_puts(ret.data.string.data);
api_free_object(ret);
}
void list_version(void)
{
msg(longVersion, 0);
msg(version_buildtype, 0);
msg_ext_set_kind("list_cmd");
msg_puts(longVersion);
msg_putchar('\n');
msg_puts(version_buildtype);
msg_putchar('\n');
list_lua_version();
if (p_verbose > 0) {
#ifndef NDEBUG
msg(version_cflags, 0);
msg_putchar('\n');
msg_puts(version_cflags);
#endif
version_msg("\n\n");

View File

@ -534,6 +534,42 @@ describe('ui/ext_messages', function()
},
},
})
command('command Foo Bar')
feed(':command<CR>')
screen:expect({
grid = [[
line 1 |
^line |
{1:~ }|*3
]],
cmdline = { { abort = false } },
messages = {
{
content = {
{ '\n Name Args Address Complete Definition', 101, 23 },
{ '\n ' },
{ 'Foo', 18, 5 },
{ ' 0 Bar' },
},
kind = 'list_cmd',
},
},
})
feed(':version<CR>')
screen:expect({
grid = [[
line 1 |
^line |
{1:~ }|*3
]],
cmdline = { { abort = false } },
condition = function()
eq('list_cmd', screen.messages[1].kind)
screen.messages = {}
end,
})
end)
it(':echoerr', function()

View File

@ -9,7 +9,7 @@ func Test_version()
let v2 = execute('version')
call assert_equal(v1, v2)
call assert_match("^\n\nNVIM v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+.*", v1)
call assert_match("^\nNVIM v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+.*", v1)
endfunc
func Test_version_redirect()