aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2025-01-14 17:23:11 +0100
committerLuuk van Baal <luukvbaal@gmail.com>2025-01-15 10:51:55 +0100
commitd55b17e2b4e061fd8b330f928785a217c99c9d11 (patch)
treeeabbcd7fc8cf408daf49f4614d3ee7c7ff6a8bc1 /src
parent5bae80899d9d29d80c129ca92cde75a1583b5efe (diff)
downloadrneovim-d55b17e2b4e061fd8b330f928785a217c99c9d11.tar.gz
rneovim-d55b17e2b4e061fd8b330f928785a217c99c9d11.tar.bz2
rneovim-d55b17e2b4e061fd8b330f928785a217c99c9d11.zip
fix(messages): verbose kind for nvim_echo()
Problem: No "verbose" kind for nvim_echo() opts->verbose. Solution: Pass NULL "kind" to indicate no new kind.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c3
-rw-r--r--src/nvim/message.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index faf6c0567c..950c70026b 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -772,7 +772,8 @@ void nvim_echo(Array chunks, Boolean history, Dict(echo_opts) *opts, Error *err)
verbose_enter();
}
- msg_multihl(hl_msg, opts->err ? "echoerr" : history ? "echomsg" : "echo", history, opts->err);
+ char *kind = opts->verbose ? NULL : opts->err ? "echoerr" : history ? "echomsg" : "echo";
+ msg_multihl(hl_msg, kind, history, opts->err);
if (opts->verbose) {
verbose_leave();
diff --git a/src/nvim/message.c b/src/nvim/message.c
index f87eba27d0..5423446ef9 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -296,6 +296,12 @@ void msg_multiline(String str, int hl_id, bool check_int, bool hist, bool *need_
// Avoid starting a new message for each chunk and adding message to history in msg_keep().
static bool is_multihl = false;
+/// Print message chunks, each with their own highlight ID.
+///
+/// @param hl_msg Message chunks
+/// @param kind Message kind (can be NULL to avoid setting kind)
+/// @param history Whether to add message to history
+/// @param err Whether to print message as an error
void msg_multihl(HlMessage hl_msg, const char *kind, bool history, bool err)
{
no_wait_return++;
@@ -303,7 +309,9 @@ void msg_multihl(HlMessage hl_msg, const char *kind, bool history, bool err)
msg_clr_eos();
bool need_clear = false;
msg_ext_history = history;
- msg_ext_set_kind(kind);
+ if (kind != NULL) {
+ msg_ext_set_kind(kind);
+ }
is_multihl = true;
for (uint32_t i = 0; i < kv_size(hl_msg); i++) {
HlMessageChunk chunk = kv_A(hl_msg, i);
@@ -312,7 +320,7 @@ void msg_multihl(HlMessage hl_msg, const char *kind, bool history, bool err)
} else {
msg_multiline(chunk.text, chunk.hl_id, true, false, &need_clear);
}
- assert(!ui_has(kUIMessages) || msg_ext_kind == kind);
+ assert(!ui_has(kUIMessages) || kind == NULL || msg_ext_kind == kind);
}
if (history && kv_size(hl_msg)) {
add_msg_hist_multihl(NULL, 0, 0, true, hl_msg);