mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 02:34:59 -07:00
fix(messages): more ext_messages kinds #31279
Add kinds for various commands that output a list, the 'wildmode' list, and for number prompts.
This commit is contained in:
parent
0e2f92ed79
commit
1b6442034f
@ -795,13 +795,16 @@ must handle.
|
||||
"echo" |:echo| message
|
||||
"echomsg" |:echomsg| message
|
||||
"echoerr" |:echoerr| message
|
||||
"list_cmd" List output for various commands (|:ls|, |:set|, …)
|
||||
"lua_error" Error in |:lua| code
|
||||
"lua_print" |print()| from |:lua| code
|
||||
"rpc_error" Error response from |rpcrequest()|
|
||||
"number_prompt" Number input prompt (|inputlist()|, |z=|, …)
|
||||
"return_prompt" |press-enter| prompt after a multiple messages
|
||||
"quickfix" Quickfix navigation message
|
||||
"search_cmd" Entered search command
|
||||
"search_count" Search count message ("S" flag of 'shortmess')
|
||||
"wildlist" 'wildmode' "list" message
|
||||
"wmsg" Warning ("search hit BOTTOM", |W10|, …)
|
||||
New kinds may be added in the future; clients should treat unknown
|
||||
kinds as the empty kind.
|
||||
|
@ -2819,6 +2819,7 @@ void buflist_list(exarg_T *eap)
|
||||
garray_T buflist;
|
||||
buf_T **buflist_data = NULL;
|
||||
|
||||
msg_ext_set_kind("list_cmd");
|
||||
if (vim_strchr(eap->arg, 't')) {
|
||||
ga_init(&buflist, sizeof(buf_T *), 50);
|
||||
for (buf = firstbuf; buf != NULL; buf = buf->b_next) {
|
||||
|
@ -1084,6 +1084,7 @@ int showmatches(expand_T *xp, bool wildmenu)
|
||||
ui_flush();
|
||||
cmdline_row = msg_row;
|
||||
msg_didany = false; // lines_left will be set again
|
||||
msg_ext_set_kind("wildlist");
|
||||
msg_start(); // prepare for paging
|
||||
}
|
||||
|
||||
|
@ -3540,6 +3540,7 @@ static void f_inputlist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
return;
|
||||
}
|
||||
|
||||
msg_ext_set_kind("list_cmd");
|
||||
msg_start();
|
||||
msg_row = Rows - 1; // for when 'cmdheight' > 1
|
||||
lines_left = Rows; // avoid more prompt
|
||||
|
@ -1403,6 +1403,7 @@ static void list_one_var(dictitem_T *v, const char *prefix, int *first)
|
||||
static void list_one_var_a(const char *prefix, const char *name, const ptrdiff_t name_len,
|
||||
const VarType type, const char *string, int *first)
|
||||
{
|
||||
msg_ext_set_kind("list_cmd");
|
||||
// don't use msg() to avoid overwriting "v:statusmsg"
|
||||
msg_start();
|
||||
msg_puts(prefix);
|
||||
|
@ -980,8 +980,6 @@ void handle_did_throw(void)
|
||||
force_abort = true;
|
||||
}
|
||||
|
||||
msg_ext_set_kind("emsg"); // kind=emsg for :throw, exceptions. #9993
|
||||
|
||||
if (messages != NULL) {
|
||||
do {
|
||||
msglist_T *next = messages->next;
|
||||
|
@ -1001,6 +1001,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
||||
{
|
||||
// If no argument, list current highlighting.
|
||||
if (!init && ends_excmd((uint8_t)(*line))) {
|
||||
msg_ext_set_kind("list_cmd");
|
||||
for (int i = 1; i <= highlight_ga.ga_len && !got_int; i++) {
|
||||
// TODO(brammool): only call when the group has attributes set
|
||||
highlight_list_one(i);
|
||||
@ -1038,6 +1039,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
|
||||
if (id == 0) {
|
||||
semsg(_(e_highlight_group_name_not_found_str), line);
|
||||
} else {
|
||||
msg_ext_set_kind("list_cmd");
|
||||
highlight_list_one(id);
|
||||
}
|
||||
return;
|
||||
|
@ -223,6 +223,7 @@ int get_number(int colon, bool *mouse_used)
|
||||
/// the line number.
|
||||
int prompt_for_number(bool *mouse_used)
|
||||
{
|
||||
msg_ext_set_kind("number_prompt");
|
||||
// When using ":silent" assume that <CR> was entered.
|
||||
if (mouse_used != NULL) {
|
||||
msg_puts(_("Type number and <Enter> or click with the mouse "
|
||||
|
@ -581,6 +581,9 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
const bool has_lhs = (args->lhs[0] != NUL);
|
||||
const bool has_rhs = args->rhs_lua != LUA_NOREF || (args->rhs[0] != NUL) || args->rhs_is_noop;
|
||||
const bool do_print = !has_lhs || (maptype != MAPTYPE_UNMAP && !has_rhs);
|
||||
if (do_print) {
|
||||
msg_ext_set_kind("list_cmd");
|
||||
}
|
||||
|
||||
// check for :unmap without argument
|
||||
if (maptype == MAPTYPE_UNMAP && !has_lhs) {
|
||||
|
@ -750,6 +750,10 @@ bool emsg_multiline(const char *s, bool multiline)
|
||||
msg_scroll = true;
|
||||
msg_source(hl_id);
|
||||
|
||||
if (msg_ext_kind == NULL) {
|
||||
msg_ext_set_kind("emsg");
|
||||
}
|
||||
|
||||
// Display the error message itself.
|
||||
msg_nowait = false; // Wait for this msg.
|
||||
return msg_hl_keep(s, hl_id, false, multiline);
|
||||
|
@ -1276,6 +1276,7 @@ static void do_one_set_option(int opt_flags, char **argp, bool *did_show, char *
|
||||
gotocmdline(true); // cursor at status line
|
||||
*did_show = true; // remember that we did a line
|
||||
}
|
||||
msg_ext_set_kind("list_cmd");
|
||||
showoneopt(&options[opt_idx], opt_flags);
|
||||
|
||||
if (p_verbose > 0) {
|
||||
@ -4048,6 +4049,7 @@ static void showoptions(bool all, int opt_flags)
|
||||
|
||||
vimoption_T **items = xmalloc(sizeof(vimoption_T *) * OPTION_COUNT);
|
||||
|
||||
msg_ext_set_kind("list_cmd");
|
||||
// Highlight title
|
||||
if (opt_flags & OPT_GLOBAL) {
|
||||
msg_puts_title(_("\n--- Global option values ---"));
|
||||
|
@ -516,6 +516,7 @@ void spell_suggest(int count)
|
||||
spell_find_suggest(line + curwin->w_cursor.col, badlen, &sug, limit,
|
||||
true, need_cap, true);
|
||||
|
||||
msg_ext_set_kind("list_cmd");
|
||||
if (GA_EMPTY(&sug.su_ga)) {
|
||||
msg(_("Sorry, no suggestions"), 0);
|
||||
} else if (count > 0) {
|
||||
|
@ -721,7 +721,7 @@ void ui_call_event(char *name, bool fast, Array args)
|
||||
// Prompt messages should be shown immediately so must be safe
|
||||
if (strcmp(name, "msg_show") == 0) {
|
||||
char *kind = args.items[0].data.string.data;
|
||||
fast = !kind || (strncmp(kind, "confirm", 7) != 0 && strcmp(kind, "return_prompt") != 0);
|
||||
fast = !kind || ((strncmp(kind, "confirm", 7) != 0 && strstr(kind, "_prompt") == NULL));
|
||||
}
|
||||
|
||||
map_foreach(&ui_event_cbs, ui_event_ns_id, event_cb, {
|
||||
|
@ -285,6 +285,26 @@ describe('vim.ui_attach', function()
|
||||
},
|
||||
},
|
||||
})
|
||||
feed('<esc>:call inputlist(["Select:", "One", "Two"])<cr>')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
E122: {10:Function} Foo already exists, add !|
|
||||
to replace it |
|
||||
Type number and <Enter> or click with th|
|
||||
e mouse (q or empty cancels): |
|
||||
{1:^~ }|
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = { { 'Select:\nOne\nTwo\n' } },
|
||||
kind = 'list_cmd',
|
||||
},
|
||||
{
|
||||
content = { { 'Type number and <Enter> or click with the mouse (q or empty cancels): ' } },
|
||||
kind = 'number_prompt',
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
||||
|
@ -64,7 +64,7 @@ describe('ui/ext_messages', function()
|
||||
}
|
||||
end)
|
||||
|
||||
it('msg_show kind=confirm,confirm_sub,emsg,wmsg,quickfix', function()
|
||||
it('msg_show kinds', function()
|
||||
feed('iline 1\nline 2<esc>')
|
||||
|
||||
-- kind=confirm
|
||||
@ -172,7 +172,7 @@ describe('ui/ext_messages', function()
|
||||
},
|
||||
{
|
||||
content = { { 'E605: Exception not caught: foo', 9, 7 } },
|
||||
kind = '',
|
||||
kind = 'emsg',
|
||||
},
|
||||
{
|
||||
content = { { 'Press ENTER or type command to continue', 6, 19 } },
|
||||
@ -198,6 +198,48 @@ describe('ui/ext_messages', function()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- search_cmd
|
||||
feed('?line<cr>')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
^line 1 |
|
||||
line 2 |
|
||||
{1:~ }|*3
|
||||
]],
|
||||
messages = { {
|
||||
content = { { '?line ' } },
|
||||
kind = 'search_cmd',
|
||||
} },
|
||||
})
|
||||
|
||||
-- highlight
|
||||
feed(':hi ErrorMsg<cr>')
|
||||
screen:expect({
|
||||
grid = [[
|
||||
^line 1 |
|
||||
line 2 |
|
||||
{1:~ }|*3
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = {
|
||||
{ '\nErrorMsg ' },
|
||||
{ 'xxx', 9, 7 },
|
||||
{ ' ' },
|
||||
{ 'ctermfg=', 18, 6 },
|
||||
{ '15 ' },
|
||||
{ 'ctermbg=', 18, 6 },
|
||||
{ '1 ' },
|
||||
{ 'guifg=', 18, 6 },
|
||||
{ 'White ' },
|
||||
{ 'guibg=', 18, 6 },
|
||||
{ 'Red' },
|
||||
},
|
||||
kind = 'list_cmd',
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
||||
it(':echoerr', function()
|
||||
@ -408,34 +450,6 @@ describe('ui/ext_messages', function()
|
||||
}
|
||||
end)
|
||||
|
||||
it(':hi Group output', function()
|
||||
feed(':hi ErrorMsg<cr>')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
^ |
|
||||
{1:~ }|*4
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = {
|
||||
{ '\nErrorMsg ' },
|
||||
{ 'xxx', 9, 7 },
|
||||
{ ' ' },
|
||||
{ 'ctermfg=', 18, 6 },
|
||||
{ '15 ' },
|
||||
{ 'ctermbg=', 18, 6 },
|
||||
{ '1 ' },
|
||||
{ 'guifg=', 18, 6 },
|
||||
{ 'White ' },
|
||||
{ 'guibg=', 18, 6 },
|
||||
{ 'Red' },
|
||||
},
|
||||
kind = '',
|
||||
},
|
||||
},
|
||||
}
|
||||
end)
|
||||
|
||||
it("doesn't crash with column adjustment #10069", function()
|
||||
feed(':let [x,y] = [1,2]<cr>')
|
||||
feed(':let x y<cr>')
|
||||
@ -445,8 +459,8 @@ describe('ui/ext_messages', function()
|
||||
{1:~ }|*4
|
||||
]],
|
||||
messages = {
|
||||
{ content = { { 'x #1' } }, kind = '' },
|
||||
{ content = { { 'y #2' } }, kind = '' },
|
||||
{ content = { { 'x #1' } }, kind = 'list_cmd' },
|
||||
{ content = { { 'y #2' } }, kind = 'list_cmd' },
|
||||
{
|
||||
content = { { 'Press ENTER or type command to continue', 6, 19 } },
|
||||
kind = 'return_prompt',
|
||||
@ -947,7 +961,7 @@ stack traceback:
|
||||
{ '*', 18, 1 },
|
||||
{ ' k' },
|
||||
},
|
||||
kind = '',
|
||||
kind = 'list_cmd',
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -964,10 +978,12 @@ stack traceback:
|
||||
^ |
|
||||
{1:~ }|*6
|
||||
]],
|
||||
messages = { {
|
||||
content = { { 'wildmenu wildmode' } },
|
||||
kind = '',
|
||||
} },
|
||||
messages = {
|
||||
{
|
||||
content = { { 'wildmenu wildmode' } },
|
||||
kind = 'wildlist',
|
||||
},
|
||||
},
|
||||
cmdline = {
|
||||
{
|
||||
firstc = ':',
|
||||
@ -983,43 +999,46 @@ stack traceback:
|
||||
feed('ihelllo<esc>')
|
||||
|
||||
feed('z=')
|
||||
screen:expect {
|
||||
screen:expect({
|
||||
grid = [[
|
||||
{100:helllo} |
|
||||
{1:~ }|*3
|
||||
{1:^~ }|
|
||||
]],
|
||||
{100:helllo} |
|
||||
{1:~ }|*3
|
||||
{1:^~ }|
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = {
|
||||
{
|
||||
'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
|
||||
},
|
||||
},
|
||||
kind = '',
|
||||
content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\n' } },
|
||||
kind = 'list_cmd',
|
||||
},
|
||||
{
|
||||
content = { { 'Type number and <Enter> or click with the mouse (q or empty cancels): ' } },
|
||||
kind = 'number_prompt',
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
feed('1')
|
||||
screen:expect {
|
||||
screen:expect({
|
||||
grid = [[
|
||||
{100:helllo} |
|
||||
{1:~ }|*3
|
||||
{1:^~ }|
|
||||
]],
|
||||
{100:helllo} |
|
||||
{1:~ }|*3
|
||||
{1:^~ }|
|
||||
]],
|
||||
messages = {
|
||||
{
|
||||
content = {
|
||||
{
|
||||
'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
|
||||
},
|
||||
},
|
||||
content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\n' } },
|
||||
kind = 'list_cmd',
|
||||
},
|
||||
{
|
||||
content = { { 'Type number and <Enter> or click with the mouse (q or empty cancels): ' } },
|
||||
kind = 'number_prompt',
|
||||
},
|
||||
{
|
||||
content = { { '1' } },
|
||||
kind = '',
|
||||
},
|
||||
{ content = { { '1' } }, kind = '' },
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
feed('<cr>')
|
||||
screen:expect {
|
||||
@ -1056,7 +1075,7 @@ stack traceback:
|
||||
{1:~ }|*4
|
||||
]],
|
||||
messages = {
|
||||
{ content = { { '\n 1 %a "[No Name]" line 1' } }, kind = '' },
|
||||
{ content = { { '\n 1 %a "[No Name]" line 1' } }, kind = 'list_cmd' },
|
||||
},
|
||||
}
|
||||
|
||||
@ -1140,18 +1159,6 @@ stack traceback:
|
||||
exec_lua([[vim.print({ foo = "bar" })]])
|
||||
screen:expect_unchanged()
|
||||
end)
|
||||
|
||||
it('emits single message for normal search)', function()
|
||||
feed('ax<cr>x<esc>?x<cr>')
|
||||
screen:expect({
|
||||
messages = {
|
||||
{
|
||||
content = { { '?x ' } },
|
||||
kind = 'search_cmd',
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('ui/builtin messages', function()
|
||||
@ -1887,7 +1894,7 @@ describe('ui/ext_messages', function()
|
||||
{3:[No Name] }|
|
||||
]],
|
||||
messages = {
|
||||
{ content = { { ' cmdheight=0' } }, kind = '' },
|
||||
{ content = { { ' cmdheight=0' } }, kind = 'list_cmd' },
|
||||
},
|
||||
})
|
||||
|
||||
@ -1903,7 +1910,7 @@ describe('ui/ext_messages', function()
|
||||
{3:[No Name] }|
|
||||
]],
|
||||
messages = {
|
||||
{ content = { { ' laststatus=3' } }, kind = '' },
|
||||
{ content = { { ' laststatus=3' } }, kind = 'list_cmd' },
|
||||
},
|
||||
})
|
||||
|
||||
@ -1923,7 +1930,7 @@ describe('ui/ext_messages', function()
|
||||
{3:[No Name] }|
|
||||
]],
|
||||
messages = {
|
||||
{ content = { { ' cmdheight=0' } }, kind = '' },
|
||||
{ content = { { ' cmdheight=0' } }, kind = 'list_cmd' },
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user