Merge pull request #31167 from luukvbaal/msgid

fix(messages): pass previous highlight id to ext chunks
This commit is contained in:
bfredl
2024-11-11 20:04:07 +01:00
committed by GitHub
2 changed files with 13 additions and 13 deletions

View File

@@ -139,7 +139,7 @@ static const char *msg_ext_kind = NULL;
static Array *msg_ext_chunks = NULL; static Array *msg_ext_chunks = NULL;
static garray_T msg_ext_last_chunk = GA_INIT(sizeof(char), 40); static garray_T msg_ext_last_chunk = GA_INIT(sizeof(char), 40);
static sattr_T msg_ext_last_attr = -1; static sattr_T msg_ext_last_attr = -1;
static int msg_ext_hl_id; static int msg_ext_last_hl_id;
static size_t msg_ext_cur_len = 0; static size_t msg_ext_cur_len = 0;
static bool msg_ext_overwrite = false; ///< will overwrite last message static bool msg_ext_overwrite = false; ///< will overwrite last message
@@ -2128,7 +2128,7 @@ static void msg_ext_emit_chunk(void)
msg_ext_last_attr = -1; msg_ext_last_attr = -1;
String text = ga_take_string(&msg_ext_last_chunk); String text = ga_take_string(&msg_ext_last_chunk);
ADD(chunk, STRING_OBJ(text)); ADD(chunk, STRING_OBJ(text));
ADD(chunk, INTEGER_OBJ(msg_ext_hl_id)); ADD(chunk, INTEGER_OBJ(msg_ext_last_hl_id));
ADD(*msg_ext_chunks, ARRAY_OBJ(chunk)); ADD(*msg_ext_chunks, ARRAY_OBJ(chunk));
} }
@@ -2145,9 +2145,9 @@ static void msg_puts_display(const char *str, int maxlen, int hl_id, int recurse
if (ui_has(kUIMessages)) { if (ui_has(kUIMessages)) {
if (attr != msg_ext_last_attr) { if (attr != msg_ext_last_attr) {
msg_ext_hl_id = hl_id;
msg_ext_emit_chunk(); msg_ext_emit_chunk();
msg_ext_last_attr = attr; msg_ext_last_attr = attr;
msg_ext_last_hl_id = hl_id;
} }
// Concat pieces with the same highlight // Concat pieces with the same highlight
size_t len = maxlen < 0 ? strlen(str) : strnlen(str, (size_t)maxlen); size_t len = maxlen < 0 ? strlen(str) : strnlen(str, (size_t)maxlen);

View File

@@ -420,15 +420,15 @@ describe('ui/ext_messages', function()
{ {
content = { content = {
{ '\nErrorMsg ' }, { '\nErrorMsg ' },
{ 'xxx', 9, 0 }, { 'xxx', 9, 7 },
{ ' ' }, { ' ' },
{ 'ctermfg=', 18, 0 }, { 'ctermfg=', 18, 6 },
{ '15 ' }, { '15 ' },
{ 'ctermbg=', 18, 0 }, { 'ctermbg=', 18, 6 },
{ '1 ' }, { '1 ' },
{ 'guifg=', 18, 0 }, { 'guifg=', 18, 6 },
{ 'White ' }, { 'White ' },
{ 'guibg=', 18, 0 }, { 'guibg=', 18, 6 },
{ 'Red' }, { 'Red' },
}, },
kind = '', kind = '',
@@ -502,7 +502,7 @@ describe('ui/ext_messages', function()
items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
pos = 1, pos = 1,
}, },
showmode = { { '-- Keyword Local completion (^N^P) ', 5, 19 }, { 'match 1 of 2', 6, 19 } }, showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } },
} }
-- echomsg and showmode don't overwrite each other, this is the same -- echomsg and showmode don't overwrite each other, this is the same
@@ -524,7 +524,7 @@ describe('ui/ext_messages', function()
content = { { 'stuff' } }, content = { { 'stuff' } },
kind = 'echomsg', kind = 'echomsg',
} }, } },
showmode = { { '-- Keyword Local completion (^N^P) ', 5, 19 }, { 'match 1 of 2', 6, 19 } }, showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } },
} }
feed('<c-p>') feed('<c-p>')
@@ -544,7 +544,7 @@ describe('ui/ext_messages', function()
content = { { 'stuff' } }, content = { { 'stuff' } },
kind = 'echomsg', kind = 'echomsg',
} }, } },
showmode = { { '-- Keyword Local completion (^N^P) ', 5, 19 }, { 'match 2 of 2', 6, 19 } }, showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 2 of 2', 6, 19 } },
} }
feed('<esc>:messages<cr>') feed('<esc>:messages<cr>')
@@ -945,7 +945,7 @@ stack traceback:
{ {
content = { content = {
{ '\nn Q @@\nn Y y$\nn j ' }, { '\nn Q @@\nn Y y$\nn j ' },
{ '*', 18, 0 }, { '*', 18, 1 },
{ ' k' }, { ' k' },
}, },
kind = '', kind = '',
@@ -1044,7 +1044,7 @@ stack traceback:
]], ]],
messages = { messages = {
{ {
content = { { 'wow, ', 10, 7 }, { 'such\n\nvery ', 9, 13 }, { 'color', 8, 13 } }, content = { { 'wow, ', 10, 9 }, { 'such\n\nvery ', 9, 7 }, { 'color', 8, 13 } },
kind = 'echomsg', kind = 'echomsg',
}, },
}, },