summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-14 11:15:08 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-14 11:15:08 +0200
commit2e240bd428c0033d16f201d7f837636412358199 (patch)
tree20647e66c737c5173ab9e6a1ade64ecf062975cb
parentf6a8d420a8d2924737f713de046947dcb487550c (diff)
downloadvim-git-2e240bd428c0033d16f201d7f837636412358199.tar.gz
patch 8.2.2761: using "syn include" does not work properlyv8.2.2761
Problem: Using "syn include" does not work properly. Solution: Don't add current_syn_inc_tag to topgrp. (Jaehwang Jerry Jung, closes #8104)
-rw-r--r--src/syntax.c13
-rw-r--r--src/testdir/test_syntax.vim17
-rw-r--r--src/version.c2
3 files changed, 28 insertions, 4 deletions
diff --git a/src/syntax.c b/src/syntax.c
index d4ec0d339..c3572d843 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -5990,12 +5990,17 @@ get_id_list(
break;
}
if (name[1] == 'A')
- id = SYNID_ALLBUT;
+ id = SYNID_ALLBUT + current_syn_inc_tag;
else if (name[1] == 'T')
- id = SYNID_TOP;
+ {
+ if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER)
+ id = curwin->w_s->b_syn_topgrp;
+ else
+ id = SYNID_TOP + current_syn_inc_tag;
+ }
else
- id = SYNID_CONTAINED;
- id += current_syn_inc_tag;
+ id = SYNID_CONTAINED + current_syn_inc_tag;
+
}
else if (name[1] == '@')
{
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim
index 1a413f6ea..bc268a14b 100644
--- a/src/testdir/test_syntax.vim
+++ b/src/testdir/test_syntax.vim
@@ -920,4 +920,21 @@ func Test_syn_contained_transparent()
bw!
endfunc
+func Test_syn_include_contains_TOP()
+ let l:case = "TOP in included syntax means its group list name"
+ new
+ syntax include @INCLUDED syntax/c.vim
+ syntax region FencedCodeBlockC start=/```c/ end=/```/ contains=@INCLUDED
+
+ call setline(1, ['```c', '#if 0', 'int', '#else', 'int', '#endif', '```' ])
+ let l:expected = ["cCppOutIf2"]
+ eval AssertHighlightGroups(3, 1, l:expected, 1)
+ " cCppOutElse has contains=TOP
+ let l:expected = ["cType"]
+ eval AssertHighlightGroups(5, 1, l:expected, 1, l:case)
+ syntax clear
+ bw!
+endfunc
+
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 4861ba1a9..5372cb46c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2761,
+/**/
2760,
/**/
2759,