aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-02-21 01:40:21 +0100
committerGitHub <noreply@github.com>2025-02-20 16:40:21 -0800
commit08f7c2237767e75e2398c057aed0f10740c487b0 (patch)
tree3bd4f108f0f58345ade206c371fe7f498cbc9834
parentf4cd5a33b6b06fe77652e19eba46af107de36a2b (diff)
downloadrneovim-08f7c2237767e75e2398c057aed0f10740c487b0.tar.gz
rneovim-08f7c2237767e75e2398c057aed0f10740c487b0.tar.bz2
rneovim-08f7c2237767e75e2398c057aed0f10740c487b0.zip
fix(messages): list_cmd kind for :registers, :au[g] #32531
Problem: No kind for `:registers/autocmd/augroup` messages. `:registers` chunks are emitted as separate `msg_show` events. Solution: Add the `list_cmd` kind to the message. Introduce a new `msg_ext_skip_flush` variable to set to true around a group of to be paired message chunks.
-rw-r--r--src/nvim/autocmd.c2
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/message.h2
-rw-r--r--src/nvim/ops.c11
-rw-r--r--test/functional/ui/messages_spec.lua115
5 files changed, 82 insertions, 50 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index ad27823667..34ad734528 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -554,6 +554,7 @@ void do_augroup(char *arg, bool del_group)
current_augroup = augroup_add(arg);
} else { // ":aug": list the group names
msg_start();
+ msg_ext_set_kind("list_cmd");
String name;
int value;
@@ -855,6 +856,7 @@ void do_autocmd(exarg_T *eap, char *arg_in, int forceit)
// Print header when showing autocommands.
if (is_showing) {
// Highlight title
+ msg_ext_set_kind("list_cmd");
msg_puts_title(_("\n--- Autocommands ---"));
if (*arg == '*' || *arg == '|' || *arg == NUL) {
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 6fc102e4ff..ef4cde8a80 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -3162,6 +3162,8 @@ void msg_ext_ui_flush(void)
if (!ui_has(kUIMessages)) {
msg_ext_kind = NULL;
return;
+ } else if (msg_ext_skip_flush) {
+ return;
}
msg_ext_emit_chunk();
diff --git a/src/nvim/message.h b/src/nvim/message.h
index 13746406f9..55c58114f4 100644
--- a/src/nvim/message.h
+++ b/src/nvim/message.h
@@ -34,6 +34,8 @@ extern MessageHistoryEntry *first_msg_hist;
extern MessageHistoryEntry *last_msg_hist;
EXTERN bool msg_ext_need_clear INIT( = false);
+// Set to true to force grouping a set of message chunks into a single `cmdline_show` event.
+EXTERN bool msg_ext_skip_flush INIT( = false);
/// allocated grid for messages. Used when display+=msgsep is set, or
/// ext_multigrid is active. See also the description at msg_scroll_flush()
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 2491621fbc..6c437bcb2c 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3770,10 +3770,16 @@ void ex_display(exarg_T *eap)
}
int hl_id = HLF_8;
+ msg_ext_set_kind("list_cmd");
+ msg_ext_skip_flush = true;
// Highlight title
msg_puts_title(_("\nType Name Content"));
for (int i = -1; i < NUM_REGISTERS && !got_int; i++) {
int name = get_register_name(i);
+ if (arg != NULL && vim_strchr(arg, name) == NULL) {
+ continue; // did not ask for this register
+ }
+
switch (get_reg_type(name, NULL)) {
case kMTLineWise:
type = 'l'; break;
@@ -3783,10 +3789,6 @@ void ex_display(exarg_T *eap)
type = 'b'; break;
}
- if (arg != NULL && vim_strchr(arg, name) == NULL) {
- continue; // did not ask for this register
- }
-
if (i == -1) {
if (y_previous != NULL) {
yb = y_previous;
@@ -3890,6 +3892,7 @@ void ex_display(exarg_T *eap)
msg_puts("\n c \"= ");
dis_msg(expr_line, false);
}
+ msg_ext_skip_flush = false;
}
/// display a string for do_dis()
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 26254be58e..83abf77ae6 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -43,11 +43,12 @@ describe('ui/ext_messages', function()
it('msg_clear follows msg_show kind of confirm', function()
feed('iline 1<esc>')
feed(':call confirm("test")<cr>')
+ local s1 = [[
+ line ^1 |
+ {1:~ }|*4
+ ]]
screen:expect({
- grid = [[
- line ^1 |
- {1:~ }|*4
- ]],
+ grid = s1,
cmdline = {
{
content = { { '' } },
@@ -65,13 +66,7 @@ describe('ui/ext_messages', function()
},
})
feed('<cr>')
- screen:expect({
- grid = [[
- line ^1 |
- {1:~ }|*4
- ]],
- cmdline = { { abort = false } },
- })
+ screen:expect({ grid = s1, cmdline = { { abort = false } } })
end)
it('msg_show kinds', function()
@@ -79,12 +74,13 @@ describe('ui/ext_messages', function()
-- confirm is now cmdline prompt
feed(':echo confirm("test")<cr>')
+ local s1 = [[
+ line 1 |
+ line ^2 |
+ {1:~ }|*3
+ ]]
screen:expect({
- grid = [[
- line 1 |
- line ^2 |
- {1:~ }|*3
- ]],
+ grid = s1,
cmdline = {
{
content = { { '' } },
@@ -103,11 +99,7 @@ describe('ui/ext_messages', function()
})
feed('<cr>')
screen:expect({
- grid = [[
- line 1 |
- line ^2 |
- {1:~ }|*3
- ]],
+ grid = s1,
cmdline = { { abort = false } },
messages = {
{
@@ -169,13 +161,9 @@ describe('ui/ext_messages', function()
})
-- kind=wmsg ('wrapscan' after search reaches EOF)
- feed('uG$/i<cr>')
+ feed('uG$/i<CR>G$')
screen:expect {
- grid = [[
- l^ine 1 |
- line 2 |
- {1:~ }|*3
- ]],
+ grid = s1,
cmdline = { { abort = false } },
messages = {
{
@@ -189,6 +177,7 @@ describe('ui/ext_messages', function()
-- kind=emsg after :throw
feed(':throw "foo"<cr>')
screen:expect {
+ grid = s1,
cmdline = { { abort = false } },
messages = {
{
@@ -212,13 +201,9 @@ describe('ui/ext_messages', function()
-- kind=quickfix after :cnext
feed('<c-c>')
command("caddexpr [expand('%').':1:line1',expand('%').':2:line2']")
- feed(':cnext<cr>')
+ feed(':cnext<CR>$')
screen:expect {
- grid = [[
- line 1 |
- ^line 2 |
- {1:~ }|*3
- ]],
+ grid = s1,
cmdline = { { abort = false } },
messages = {
{
@@ -230,13 +215,9 @@ describe('ui/ext_messages', function()
}
-- search_cmd
- feed('?line<cr>')
+ feed('?line<CR>G$')
screen:expect({
- grid = [[
- ^line 1 |
- line 2 |
- {1:~ }|*3
- ]],
+ grid = s1,
cmdline = { { abort = false } },
messages = {
{
@@ -248,8 +229,9 @@ describe('ui/ext_messages', function()
})
-- highlight
- feed(':filter character highlight<CR>')
+ feed('G$:filter character highlight<CR>')
screen:expect({
+ grid = s1,
cmdline = { { abort = false } },
messages = {
{
@@ -287,12 +269,13 @@ describe('ui/ext_messages', function()
})
feed('<C-r><C-r><C-r>')
+ local s2 = [[
+ line 1 |
+ line^ |
+ {1:~ }|*3
+ ]]
screen:expect({
- grid = [[
- line 1 |
- line^ |
- {1:~ }|*3
- ]],
+ grid = s2,
messages = {
{
content = { { 'Already at newest change' } },
@@ -306,6 +289,7 @@ describe('ui/ext_messages', function()
command('set noshowmode')
feed('i<C-n>')
screen:expect({
+ grid = s2,
messages = {
{
content = { { 'The only match' } },
@@ -314,12 +298,13 @@ describe('ui/ext_messages', function()
},
},
})
- feed('<Esc>')
+ feed('<Esc>l')
command('set showmode')
-- kind=echoerr for nvim_echo() err
feed(':call nvim_echo([["Error"], ["Message", "Special"]], 1, #{ err:1 })<CR>')
screen:expect({
+ grid = s2,
cmdline = { { abort = false } },
messages = {
{
@@ -333,6 +318,7 @@ describe('ui/ext_messages', function()
-- kind=verbose for nvim_echo() verbose
feed(':call nvim_echo([["Verbose Message"]], 1, #{ verbose:1 })<CR>')
screen:expect({
+ grid = s2,
cmdline = { { abort = false } },
messages = {
{
@@ -346,6 +332,7 @@ describe('ui/ext_messages', function()
-- kind=verbose for :verbose messages
feed(':1verbose filter Diff[AC] hi<CR>')
screen:expect({
+ grid = s2,
cmdline = { { abort = false } },
messages = {
{
@@ -439,6 +426,7 @@ describe('ui/ext_messages', function()
or '{ echo stdout; echo stderr >&2; exit 3; }'
feed((':!%s<CR>'):format(cmd))
screen:expect({
+ grid = s2,
cmdline = { { abort = false } },
messages = {
{
@@ -468,6 +456,41 @@ describe('ui/ext_messages', function()
},
},
})
+
+ feed('<CR>:registers .<CR>')
+ screen:expect({
+ grid = s2,
+ cmdline = { {
+ abort = false,
+ } },
+ messages = {
+ {
+ content = { { '\nType Name Content', 101, 23 }, { '\n c ". ' } },
+ history = false,
+ kind = 'list_cmd',
+ },
+ },
+ })
+
+ feed(':au ChanInfo * foo<CR>:au ChanInfo<CR>')
+ screen:expect({
+ grid = s2,
+ cmdline = { {
+ abort = false,
+ } },
+ messages = {
+ {
+ content = {
+ { '\n--- Autocommands ---', 101, 23 },
+ { '\n' },
+ { 'ChanInfo', 101, 23 },
+ { '\n*foo' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ },
+ })
end)
it(':echoerr', function()