diff options
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 5e54354ea8..e91d560284 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -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; } |