From e694e564220acc58b1cb4132ad3c8a0fa02067d9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 23 Jun 2022 13:01:31 +0800 Subject: vim-patch:8.2.2068: transparent syntax item uses start/end of containing region (#19055) Problem: Transparent syntax item uses start/end of containing region. Solution: Do not change the startpos and endpos of a transparent region to that of its containing region. (Adrian Ghizaru, closes vim/vim#7349, closes vim/vim#7391) https://github.com/vim/vim/commit/b46f57e87b3706a8c4b97d8e03f7853a7938b061 --- src/nvim/testdir/test_syntax.vim | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'src/nvim/testdir/test_syntax.vim') diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 6bef61ae8f..c46bba04e3 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -778,6 +778,82 @@ func Test_search_syntax_skip() bwipe! endfunc +func Test_syn_contained_transparent() + " Comments starting with "Regression:" show the result when the highlighting + " span of the containing item is assigned to the contained region. + syntax on + + let l:case = "Transparent region contained in region" + new + syntax region X start=/\[/ end=/\]/ contained transparent + syntax region Y start=/(/ end=/)/ contains=X + + call setline(1, "==(--[~~]--)==") + let l:expected = " YYYYYYYYYY " + eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) + syntax clear Y X + bw! + + let l:case = "Transparent region extends region" + new + syntax region X start=/\[/ end=/\]/ contained transparent + syntax region Y start=/(/ end=/)/ end=/e/ contains=X + + call setline(1, "==(--[~~e~~]--)==") + let l:expected = " YYYYYYYYYYYYY " + " Regression: " YYYYYYY YYY " + eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) + syntax clear Y X + bw! + + let l:case = "Nested transparent regions extend region" + new + syntax region X start=/\[/ end=/\]/ contained transparent + syntax region Y start=/(/ end=/)/ end=/e/ contains=X + + call setline(1, "==(--[~~e~~[~~e~~]~~e~~]--)==") + let l:expected = " YYYYYYYYYYYYYYYYYYYYYYYYY " + " Regression: " YYYYYYY YYYYYYYYY " + eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) + syntax clear Y X + bw! + + let l:case = "Transparent region contained in match" + new + syntax region X start=/\[/ end=/\]/ contained transparent + syntax match Y /(.\{-})/ contains=X + + call setline(1, "==(--[~~]--)==") + let l:expected = " YYYYYYYYYY " + eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) + syntax clear Y X + bw! + + let l:case = "Transparent region extends match" + new + syntax region X start=/\[/ end=/\]/ contained transparent + syntax match Y /(.\{-}[e)]/ contains=X + + call setline(1, "==(--[~~e~~]--)==") + let l:expected = " YYYYYYYYYY " + " Regression: " YYYYYYY " + eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) + syntax clear Y X + bw! + + let l:case = "Nested transparent regions extend match" + new + syntax region X start=/\[/ end=/\]/ contained transparent + syntax match Y /(.\{-}[e)]/ contains=X + + call setline(1, "==(--[~~e~~[~~e~~]~~e~~]--)==") + let l:expected = " YYYYYYYYYYYYYYYYYYYYYY " + " Regression: " YYYYYYY YYYYYY " + eval AssertHighlightGroups(1, 1, l:expected, 1, l:case) + syntax clear Y X + bw! +endfunc + func Test_syn_include_contains_TOP() let l:case = "TOP in included syntax means its group list name" new -- cgit