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)
b46f57e87b
This commit is contained in:
zeertzjq 2022-06-23 13:01:31 +08:00 committed by GitHub
parent 1b75094e3e
commit e694e56422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 2 deletions

View File

@ -2381,8 +2381,6 @@ static void update_si_attr(int idx)
} else { } else {
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;
sip->si_cont_list = CUR_STATE(idx - 1).si_cont_list; sip->si_cont_list = CUR_STATE(idx - 1).si_cont_list;

View File

@ -778,6 +778,82 @@ 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
func Test_syn_include_contains_TOP() 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 means its group list name"
new new