refactor(message): propagate highlight id instead of attrs

Problem:  Highlight group id is not propagated to the end of the message call
          stack, where ext_messages are emitted.
Solution: Refactor message functions to pass along highlight group id
          instead of attr id.
This commit is contained in:
Luuk van Baal
2024-02-20 17:25:57 +01:00
parent 5a86360400
commit 5cfa7a72f8
45 changed files with 441 additions and 473 deletions

View File

@@ -824,16 +824,15 @@ HlMessage parse_hl_msg(Array chunks, Error *err)
String str = copy_string(chunk.items[0].data.string, NULL);
int attr = 0;
int hl_id = 0;
if (chunk.size == 2) {
String hl = chunk.items[1].data.string;
if (hl.size > 0) {
// TODO(bfredl): use object_to_hl_id and allow integer
int hl_id = syn_check_group(hl.data, hl.size);
attr = hl_id > 0 ? syn_id2attr(hl_id) : 0;
hl_id = syn_check_group(hl.data, hl.size);
}
}
kv_push(hl_msg, ((HlMessageChunk){ .text = str, .attr = attr }));
kv_push(hl_msg, ((HlMessageChunk){ .text = str, .hl_id = hl_id }));
}
return hl_msg;

View File

@@ -796,7 +796,7 @@ void nvim_echo(Array chunks, Boolean history, Dict(echo_opts) *opts, Error *err)
verbose_enter();
}
msg_multiattr(hl_msg, history ? "echomsg" : "echo", history);
msg_multihl(hl_msg, history ? "echomsg" : "echo", history);
if (opts->verbose) {
verbose_leave();