aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-01-13 13:59:34 +0100
committerGitHub <noreply@github.com>2025-01-13 04:59:34 -0800
commitcb7b4e296238b46025de05203c886d67da401728 (patch)
tree660ce0d42e77c294b40d2808ddfb3899a12d427d
parent47866cd8d20c62afa8a3c3929d3aada2db9162f5 (diff)
downloadrneovim-cb7b4e296238b46025de05203c886d67da401728.tar.gz
rneovim-cb7b4e296238b46025de05203c886d67da401728.tar.bz2
rneovim-cb7b4e296238b46025de05203c886d67da401728.zip
feat(messages): "verbose" message kind #31991
-rw-r--r--runtime/doc/news.txt2
-rw-r--r--runtime/doc/ui.txt1
-rw-r--r--src/nvim/message.c24
-rw-r--r--test/functional/ui/messages_spec.lua50
4 files changed, 68 insertions, 9 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index a1868e97d0..3edf146b19 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -96,7 +96,7 @@ EVENTS
• `msg_show`:
• `history` argument indicating if the message was added to the history.
• new message kinds: "bufwrite", "completion", "list_cmd", "lua_print",
- "search_cmd", "undo", "wildlist".
+ "search_cmd", "undo", "verbose", wildlist".
HIGHLIGHTS
diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt
index 8f25133e7a..26ea03d2be 100644
--- a/runtime/doc/ui.txt
+++ b/runtime/doc/ui.txt
@@ -806,6 +806,7 @@ must handle.
"search_cmd" Entered search command
"search_count" Search count message ("S" flag of 'shortmess')
"undo" |:undo| and |:redo| message
+ "verbose" 'verbose' message
"wildlist" 'wildmode' "list" message
"wmsg" Warning ("search hit BOTTOM", |W10|, …)
New kinds may be added in the future; clients should treat unknown
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 12d980f58f..f87eba27d0 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -3324,6 +3324,10 @@ int redirecting(void)
|| redir_reg || redir_vname || capture_ga != NULL;
}
+// Save and restore message kind when emitting a verbose message.
+static const char *pre_verbose_kind = NULL;
+static const char *verbose_kind = "verbose";
+
/// Before giving verbose message.
/// Must always be called paired with verbose_leave()!
void verbose_enter(void)
@@ -3331,6 +3335,10 @@ void verbose_enter(void)
if (*p_vfile != NUL) {
msg_silent++;
}
+ if (msg_ext_kind != verbose_kind) {
+ pre_verbose_kind = msg_ext_kind;
+ msg_ext_set_kind("verbose");
+ }
}
/// After giving verbose message.
@@ -3342,14 +3350,17 @@ void verbose_leave(void)
msg_silent = 0;
}
}
+ if (pre_verbose_kind != NULL) {
+ msg_ext_set_kind(pre_verbose_kind);
+ pre_verbose_kind = NULL;
+ }
}
/// Like verbose_enter() and set msg_scroll when displaying the message.
void verbose_enter_scroll(void)
{
- if (*p_vfile != NUL) {
- msg_silent++;
- } else {
+ verbose_enter();
+ if (*p_vfile == NUL) {
// always scroll up, don't overwrite
msg_scroll = true;
}
@@ -3358,11 +3369,8 @@ void verbose_enter_scroll(void)
/// Like verbose_leave() and set cmdline_row when displaying the message.
void verbose_leave_scroll(void)
{
- if (*p_vfile != NUL) {
- if (--msg_silent < 0) {
- msg_silent = 0;
- }
- } else {
+ verbose_leave();
+ if (*p_vfile == NUL) {
cmdline_row = msg_row;
}
}
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 06048c665c..ea4edefe8a 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -330,6 +330,56 @@ describe('ui/ext_messages', function()
},
},
})
+
+ feed(':1verbose filter Diff[AC] hi<CR>')
+ screen:expect({
+ cmdline = { {
+ abort = false,
+ } },
+ messages = {
+ {
+ content = {
+ { '\nDiffAdd ' },
+ { 'xxx', 22, 30 },
+ { ' ' },
+ { 'ctermbg=', 18, 5 },
+ { '81 ' },
+ { 'guibg=', 18, 5 },
+ { 'LightBlue' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ {
+ content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
+ history = false,
+ kind = 'verbose',
+ },
+ {
+ content = {
+ { '\nDiffChange ' },
+ { 'xxx', 4, 31 },
+ { ' ' },
+ { 'ctermbg=', 18, 5 },
+ { '225 ' },
+ { 'guibg=', 18, 5 },
+ { 'LightMagenta' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ {
+ content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
+ history = false,
+ kind = 'verbose',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
+ kind = 'return_prompt',
+ },
+ },
+ })
end)
it(':echoerr', function()