1
0
forked from aniani/vim

patch 9.1.1077: included syntax items do not understand contains=TOP

Problem:  Syntax engine interpreted contains=TOP as matching nothing
          inside included files, since :syn-include forces HL_CONTAINED
          on for every included item. After 8.2.2761, interprets
          contains=TOP as contains=@INCLUDED, which is also not correct
          since it doesn't respect exclusions, and doesn't work if there
          is no @INCLUDED cluster.
Solution: revert patch 8.2.2761, instead track groups that have had
          HL_CONTAINED forced, and interpret contains=TOP and
          contains=CONTAINED using this. (Theodore Dubois)

fixes: #11277
closes: #16571

Signed-off-by: Theodore Dubois <tblodt@icloud.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Theodore Dubois
2025-02-05 23:59:25 +01:00
committed by Christian Brabandt
parent 34e1e8de91
commit f50d5364d7
4 changed files with 38 additions and 20 deletions

View File

@@ -949,7 +949,7 @@ func Test_syn_contained_transparent()
endfunc
func Test_syn_include_contains_TOP()
let l:case = "TOP in included syntax means its group list name"
let l:case = "TOP in included syntax refers to top level of that included syntax"
new
syntax include @INCLUDED syntax/c.vim
syntax region FencedCodeBlockC start=/```c/ end=/```/ contains=@INCLUDED
@@ -964,6 +964,18 @@ func Test_syn_include_contains_TOP()
bw!
endfunc
func Test_syn_include_contains_TOP_excluding()
new
syntax include @INCLUDED syntax/c.vim
syntax region FencedCodeBlockC start=/```c/ end=/```/ contains=@INCLUDED
call setline(1, ['```c', '#if 0', 'int', '#else', 'int', '#if', '#endif', '```' ])
let l:expected = ["cCppOutElse", "cConditional"]
eval AssertHighlightGroups(6, 1, l:expected, 1)
syntax clear
bw!
endfunc
" This was using freed memory
func Test_WinEnter_synstack_synID()
autocmd WinEnter * call synstack(line("."), col("."))