mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge #35628 fix(progress): msg-id, memoryleak
This commit is contained in:
@@ -352,6 +352,7 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo
|
|||||||
msg_start();
|
msg_start();
|
||||||
msg_clr_eos();
|
msg_clr_eos();
|
||||||
bool need_clear = false;
|
bool need_clear = false;
|
||||||
|
bool hl_msg_updated = false;
|
||||||
msg_ext_history = history;
|
msg_ext_history = history;
|
||||||
if (kind != NULL) {
|
if (kind != NULL) {
|
||||||
msg_ext_set_kind(kind);
|
msg_ext_set_kind(kind);
|
||||||
@@ -368,12 +369,14 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo
|
|||||||
msg_id_next = id.data.integer + 1;
|
msg_id_next = id.data.integer + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
msg_ext_id = id;
|
||||||
|
|
||||||
// progress message are special displayed as "title: percent% msg"
|
// progress message are special displayed as "title: percent% msg"
|
||||||
if (strequal(kind, "progress") && msg_data) {
|
if (strequal(kind, "progress") && msg_data) {
|
||||||
HlMessage formated_message = format_progress_message(hl_msg, msg_data);
|
HlMessage formated_message = format_progress_message(hl_msg, msg_data);
|
||||||
if (formated_message.items != hl_msg.items) {
|
if (formated_message.items != hl_msg.items) {
|
||||||
*needs_msg_clear = true;
|
*needs_msg_clear = true;
|
||||||
|
hl_msg_updated = true;
|
||||||
hl_msg = formated_message;
|
hl_msg = formated_message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -396,6 +399,10 @@ MsgID msg_multihl(MsgID id, HlMessage hl_msg, const char *kind, bool history, bo
|
|||||||
is_multihl = false;
|
is_multihl = false;
|
||||||
no_wait_return--;
|
no_wait_return--;
|
||||||
msg_end();
|
msg_end();
|
||||||
|
|
||||||
|
if (hl_msg_updated && !(history && kv_size(hl_msg))) {
|
||||||
|
hl_msg_free(hl_msg);
|
||||||
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1161,7 +1168,6 @@ static void msg_hist_add_multihl(MsgID msg_id, HlMessage msg, bool temp, Message
|
|||||||
msg_hist_last = entry;
|
msg_hist_last = entry;
|
||||||
msg_ext_history = true;
|
msg_ext_history = true;
|
||||||
|
|
||||||
msg_ext_id = msg_id;
|
|
||||||
msg_hist_clear(msg_hist_max);
|
msg_hist_clear(msg_hist_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3640,4 +3640,41 @@ describe('progress-message', function()
|
|||||||
{6:TestSuit}: {19: 10% }test-message |
|
{6:TestSuit}: {19: 10% }test-message |
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('works with history off', function()
|
||||||
|
api.nvim_echo({ { 'test-message' } }, false, {
|
||||||
|
kind = 'progress',
|
||||||
|
title = 'TestSuit',
|
||||||
|
percent = 10,
|
||||||
|
status = 'running',
|
||||||
|
})
|
||||||
|
|
||||||
|
screen:expect({
|
||||||
|
grid = [[
|
||||||
|
^ |
|
||||||
|
{1:~ }|*4
|
||||||
|
]],
|
||||||
|
messages = {
|
||||||
|
{
|
||||||
|
content = {
|
||||||
|
{ 'TestSuit', 6, 'MoreMsg' },
|
||||||
|
{ ': ' },
|
||||||
|
{ ' 10% ', 19, 'WarningMsg' },
|
||||||
|
{ 'test-message' },
|
||||||
|
},
|
||||||
|
id = 1,
|
||||||
|
kind = 'progress',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
assert_progress_autocmd({
|
||||||
|
text = { 'test-message' },
|
||||||
|
percent = 10,
|
||||||
|
status = 'running',
|
||||||
|
title = 'TestSuit',
|
||||||
|
id = 1,
|
||||||
|
data = {},
|
||||||
|
}, 'progress autocmd receives progress messages')
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user