mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
decorations: allow nvim_set_hl to break existing links
also add `default` flag to NOT break existing links/defs
This commit is contained in:
@@ -7563,14 +7563,13 @@ static void syn_unadd_group(void)
|
||||
/// @see syn_attr2entry
|
||||
int syn_id2attr(int hl_id)
|
||||
{
|
||||
struct hl_group *sgp;
|
||||
|
||||
hl_id = syn_get_final_id(hl_id);
|
||||
int attr = ns_get_hl(-1, hl_id, false);
|
||||
struct hl_group *sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
|
||||
|
||||
int attr = ns_get_hl(-1, hl_id, false, sgp->sg_set);
|
||||
if (attr >= 0) {
|
||||
return attr;
|
||||
}
|
||||
sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
|
||||
return sgp->sg_attr;
|
||||
}
|
||||
|
||||
@@ -7583,7 +7582,6 @@ int syn_id2attr(int hl_id)
|
||||
int syn_get_final_id(int hl_id)
|
||||
{
|
||||
int count;
|
||||
struct hl_group *sgp;
|
||||
|
||||
if (hl_id > highlight_ga.ga_len || hl_id < 1)
|
||||
return 0; /* Can be called from eval!! */
|
||||
@@ -7593,19 +7591,20 @@ int syn_get_final_id(int hl_id)
|
||||
* Look out for loops! Break after 100 links.
|
||||
*/
|
||||
for (count = 100; --count >= 0; ) {
|
||||
struct hl_group *sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
|
||||
|
||||
// ACHTUNG: when using "tmp" attribute (no link) the function might be
|
||||
// called twice. it needs be smart enough to remember attr only to
|
||||
// syn_id2attr time
|
||||
int check = ns_get_hl(-1, hl_id, true);
|
||||
int check = ns_get_hl(-1, hl_id, true, sgp->sg_set);
|
||||
if (check == 0) {
|
||||
return 0; // how dare! it broke the link!
|
||||
return hl_id; // how dare! it broke the link!
|
||||
} else if (check > 0) {
|
||||
hl_id = check;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
|
||||
if (sgp->sg_link == 0 || sgp->sg_link > highlight_ga.ga_len) {
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user