mirror of
https://github.com/neovim/neovim.git
synced 2026-04-01 13:22:08 +00:00
fix(messages): adjust msg_show "empty" kind logic (#37427)
Problem: A message ending in an unprintable character may emit a
msg_show event with the "empty" kind. No empty message event
for echom "".
Solution: Adjust conditions for emitting "empty" msg_show events.
This commit is contained in:
@@ -286,8 +286,10 @@ void msg_multiline(String str, int hl_id, bool check_int, bool hist, bool *need_
|
|||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the rest of the message
|
// Print the remainder or emit empty event if entire message is empty.
|
||||||
msg_outtrans_len(chunk, (int)(str.size - (size_t)(chunk - str.data)), hl_id, hist);
|
if (*chunk != NUL || chunk == str.data) {
|
||||||
|
msg_outtrans_len(chunk, (int)(str.size - (size_t)(chunk - str.data)), hl_id, hist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid starting a new message for each chunk and adding message to history in msg_keep().
|
// Avoid starting a new message for each chunk and adding message to history in msg_keep().
|
||||||
@@ -1748,7 +1750,7 @@ static void msg_home_replace_hl(const char *fname, int hl_id)
|
|||||||
/// @return the number of characters it takes on the screen.
|
/// @return the number of characters it takes on the screen.
|
||||||
int msg_outtrans(const char *str, int hl_id, bool hist)
|
int msg_outtrans(const char *str, int hl_id, bool hist)
|
||||||
{
|
{
|
||||||
return *str == NUL ? 0 : msg_outtrans_len(str, (int)strlen(str), hl_id, hist);
|
return msg_outtrans_len(str, (int)strlen(str), hl_id, hist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Output one character at "p".
|
/// Output one character at "p".
|
||||||
|
|||||||
@@ -502,8 +502,8 @@ describe('ui/ext_messages', function()
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Empty messages
|
-- 3 empty message events, not for an empty chunk after a non-printable character
|
||||||
feed(':echo "foo" | echo "" | lua print()<CR>')
|
feed(':echo "foo\\n" | echo "" | echom "" | lua print()<CR>')
|
||||||
screen:expect({
|
screen:expect({
|
||||||
grid = [[
|
grid = [[
|
||||||
line 1 |
|
line 1 |
|
||||||
@@ -511,7 +511,8 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }|*3
|
{1:~ }|*3
|
||||||
]],
|
]],
|
||||||
messages = {
|
messages = {
|
||||||
{ content = { { 'foo' } }, kind = 'echo' },
|
{ content = { { 'foo\n' } }, kind = 'echo' },
|
||||||
|
{ content = {}, kind = 'empty' },
|
||||||
{ content = {}, kind = 'empty' },
|
{ content = {}, kind = 'empty' },
|
||||||
{ content = {}, kind = 'empty' },
|
{ content = {}, kind = 'empty' },
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user