mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +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;
|
bool found = false;
|
||||||
|
|
||||||
|
msg_ext_set_kind("list_cmd");
|
||||||
// In cmdwin, the alternative buffer should be used.
|
// In cmdwin, the alternative buffer should be used.
|
||||||
const garray_T *gap = &prevwin_curwin()->w_buffer->b_ucmds;
|
const garray_T *gap = &prevwin_curwin()->w_buffer->b_ucmds;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@@ -2557,7 +2557,9 @@ void ex_version(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
// Ignore a ":version 9.99" command.
|
// Ignore a ":version 9.99" command.
|
||||||
if (*eap->arg == NUL) {
|
if (*eap->arg == NUL) {
|
||||||
msg_putchar('\n');
|
if (!ui_has(kUIMessages)) {
|
||||||
|
msg_putchar('\n');
|
||||||
|
}
|
||||||
list_version();
|
list_version();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2671,19 +2673,23 @@ void list_lua_version(void)
|
|||||||
(Array)ARRAY_DICT_INIT, kRetObject, NULL, &err);
|
(Array)ARRAY_DICT_INIT, kRetObject, NULL, &err);
|
||||||
assert(!ERROR_SET(&err));
|
assert(!ERROR_SET(&err));
|
||||||
assert(ret.type == kObjectTypeString);
|
assert(ret.type == kObjectTypeString);
|
||||||
msg(ret.data.string.data, 0);
|
msg_puts(ret.data.string.data);
|
||||||
api_free_object(ret);
|
api_free_object(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void list_version(void)
|
void list_version(void)
|
||||||
{
|
{
|
||||||
msg(longVersion, 0);
|
msg_ext_set_kind("list_cmd");
|
||||||
msg(version_buildtype, 0);
|
msg_puts(longVersion);
|
||||||
|
msg_putchar('\n');
|
||||||
|
msg_puts(version_buildtype);
|
||||||
|
msg_putchar('\n');
|
||||||
list_lua_version();
|
list_lua_version();
|
||||||
|
|
||||||
if (p_verbose > 0) {
|
if (p_verbose > 0) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
msg(version_cflags, 0);
|
msg_putchar('\n');
|
||||||
|
msg_puts(version_cflags);
|
||||||
#endif
|
#endif
|
||||||
version_msg("\n\n");
|
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)
|
end)
|
||||||
|
|
||||||
it(':echoerr', function()
|
it(':echoerr', function()
|
||||||
|
@@ -9,7 +9,7 @@ func Test_version()
|
|||||||
let v2 = execute('version')
|
let v2 = execute('version')
|
||||||
call assert_equal(v1, v2)
|
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
|
endfunc
|
||||||
|
|
||||||
func Test_version_redirect()
|
func Test_version_redirect()
|
||||||
|
Reference in New Issue
Block a user