]> granicus.if.org Git - vim/commitdiff
patch 8.2.2761: using "syn include" does not work properly v8.2.2761
authorBram Moolenaar <Bram@vim.org>
Wed, 14 Apr 2021 09:15:08 +0000 (11:15 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 14 Apr 2021 09:15:08 +0000 (11:15 +0200)
Problem:    Using "syn include" does not work properly.
Solution:   Don't add current_syn_inc_tag to topgrp. (Jaehwang Jerry Jung,
            closes #8104)

src/syntax.c
src/testdir/test_syntax.vim
src/version.c

index d4ec0d339fb4211ee1892ff3fe2aa92f8d74857e..c3572d8435deb9c1663037ad9d535c87177ca339 100644 (file)
@@ -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] == '@')
            {
index 1a413f6ea9b9124faad0f97d06049edd45b07ca3..bc268a14bb533cb0f6fa52997291c976dc52263a 100644 (file)
@@ -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
index 4861ba1a9fdf5bda5fbab13f8b1d0102528e5419..5372cb46cb4de2e8c20f9c6f3e2760e80021801f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2761,
 /**/
     2760,
 /**/