aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/syntax.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-11-08 11:36:47 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2020-11-21 11:24:14 +0100
commita4986ab47f4561ca82581b1a5f7c21004b05cee9 (patch)
tree1e385debd9f2dd9b1389bf57498c64e9e3cd0e8f /src/nvim/syntax.c
parent480b04122e93826bdfc74fbeacab2d94b089420f (diff)
downloadrneovim-a4986ab47f4561ca82581b1a5f7c21004b05cee9.tar.gz
rneovim-a4986ab47f4561ca82581b1a5f7c21004b05cee9.tar.bz2
rneovim-a4986ab47f4561ca82581b1a5f7c21004b05cee9.zip
decorations: allow nvim_set_hl to break existing links
also add `default` flag to NOT break existing links/defs
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r--src/nvim/syntax.c15
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;
}