aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/message.c
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2024-12-22 13:21:57 +0100
committerLuuk van Baal <luukvbaal@gmail.com>2024-12-23 00:37:28 +0100
commita10636fbe7bb4dba45c42c64548e5e32fe8f8d12 (patch)
treea6fb8278c199c9c94a75e60419ad3700f33e00d1 /src/nvim/message.c
parent394f69a25dc32c5b101ba2d34ac6376b0c75b2a2 (diff)
downloadrneovim-a10636fbe7bb4dba45c42c64548e5e32fe8f8d12.tar.gz
rneovim-a10636fbe7bb4dba45c42c64548e5e32fe8f8d12.tar.bz2
rneovim-a10636fbe7bb4dba45c42c64548e5e32fe8f8d12.zip
feat(ui): specify whether msg_show event is added to history
Pass along whether message in msg_show event is added to the internal :messages history.
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r--src/nvim/message.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 1c46194a1c..c37232e4bc 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -153,6 +153,7 @@ static sattr_T msg_ext_last_attr = -1;
static int msg_ext_last_hl_id;
static size_t msg_ext_cur_len = 0;
+static bool msg_ext_history = false; ///< message was added to history
static bool msg_ext_overwrite = false; ///< will overwrite last message
static int msg_ext_visible = 0; ///< number of messages currently visible
@@ -988,7 +989,7 @@ static void add_msg_hist(const char *s, int len, int hl_id, bool multiline)
static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multiline,
HlMessage multihl)
{
- if (msg_hist_off || msg_silent != 0) {
+ if (msg_hist_off || msg_silent != 0 || (s != NULL && *s == NUL)) {
hl_msg_free(multihl);
return;
}
@@ -999,12 +1000,13 @@ static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multili
if (len < 0) {
len = (int)strlen(s);
}
+ assert(len > 0);
// remove leading and trailing newlines
- while (len > 0 && *s == '\n') {
+ while (*s == '\n') {
s++;
len--;
}
- while (len > 0 && s[len - 1] == '\n') {
+ while (s[len - 1] == '\n') {
len--;
}
p->msg = xmemdupz(s, (size_t)len);
@@ -1024,6 +1026,7 @@ static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multili
first_msg_hist = last_msg_hist;
}
msg_hist_len++;
+ msg_ext_history = true;
check_msg_hist();
}
@@ -3159,13 +3162,14 @@ void msg_ext_ui_flush(void)
msg_ext_emit_chunk();
if (msg_ext_chunks->size > 0) {
Array *tofree = msg_ext_init_chunks();
- ui_call_msg_show(cstr_as_string(msg_ext_kind), *tofree, msg_ext_overwrite);
+ ui_call_msg_show(cstr_as_string(msg_ext_kind), *tofree, msg_ext_overwrite, msg_ext_history);
api_free_array(*tofree);
xfree(tofree);
if (!msg_ext_overwrite) {
msg_ext_visible++;
}
msg_ext_overwrite = false;
+ msg_ext_history = false;
msg_ext_kind = NULL;
}
}