mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2068: transparent syntax item uses start/end of containing region
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 #7349, closes #7391)
This commit is contained in:
@@ -2606,8 +2606,6 @@ update_si_attr(int idx)
|
|||||||
{
|
{
|
||||||
sip->si_attr = CUR_STATE(idx - 1).si_attr;
|
sip->si_attr = CUR_STATE(idx - 1).si_attr;
|
||||||
sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id;
|
sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id;
|
||||||
sip->si_h_startpos = CUR_STATE(idx - 1).si_h_startpos;
|
|
||||||
sip->si_h_endpos = CUR_STATE(idx - 1).si_h_endpos;
|
|
||||||
if (sip->si_cont_list == NULL)
|
if (sip->si_cont_list == NULL)
|
||||||
{
|
{
|
||||||
sip->si_flags |= HL_TRANS_CONT;
|
sip->si_flags |= HL_TRANS_CONT;
|
||||||
|
@@ -27,6 +27,26 @@ func GetSyntaxItem(pat)
|
|||||||
return c
|
return c
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func AssertHighlightGroups(lnum, startcol, expected, trans = 1, msg = "")
|
||||||
|
" Assert that the characters starting at a given (line, col)
|
||||||
|
" sequentially match the expected highlight groups.
|
||||||
|
" If groups are provided as a string, each character is assumed to be a
|
||||||
|
" group and spaces represent no group, useful for visually describing tests.
|
||||||
|
let l:expectedGroups = type(a:expected) == v:t_string
|
||||||
|
\ ? a:expected->split('\zs')->map({_, v -> trim(v)})
|
||||||
|
\ : a:expected
|
||||||
|
let l:errors = 0
|
||||||
|
let l:msg = (a:msg->empty() ? "" : a:msg .. ": ")
|
||||||
|
\ .. "Wrong highlight group at " .. a:lnum .. ","
|
||||||
|
|
||||||
|
for l:i in range(a:startcol, a:startcol + l:expectedGroups->len() - 1)
|
||||||
|
let l:errors += synID(a:lnum, l:i, a:trans)
|
||||||
|
\ ->synIDattr("name")
|
||||||
|
\ ->assert_equal(l:expectedGroups[l:i - 1],
|
||||||
|
\ l:msg .. l:i)
|
||||||
|
endfor
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_syn_iskeyword()
|
func Test_syn_iskeyword()
|
||||||
new
|
new
|
||||||
call setline(1, [
|
call setline(1, [
|
||||||
@@ -824,4 +844,80 @@ func Test_search_syntax_skip()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
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
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2068,
|
||||||
/**/
|
/**/
|
||||||
2067,
|
2067,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user