mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
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:
@ -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) {
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user