0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.1056: wrong display when mixing match conceal and syntax conceal

Problem:    Wrong display when mixing match conceal and syntax conceal.
Solution:   Adjust how conceal flags are used. (closes #6327, closes #6303)
This commit is contained in:
Bram Moolenaar 2020-06-25 20:07:04 +02:00
parent 73b4465ba7
commit 211dd3fd82
4 changed files with 90 additions and 30 deletions

View File

@ -967,7 +967,7 @@ win_line(
for (;;)
{
#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
int has_match_conc = 0; // match wants to conceal
int has_match_conc = 0; // match wants to conceal
#endif
#ifdef FEAT_CONCEAL
int did_decrement_ptr = FALSE;
@ -2353,13 +2353,14 @@ win_line(
{
char_attr = conceal_attr;
if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1)
&& (syn_get_sub_char() != NUL || match_conc
|| wp->w_p_cole == 1)
&& (syn_get_sub_char() != NUL
|| (has_match_conc && match_conc)
|| wp->w_p_cole == 1)
&& wp->w_p_cole != 3)
{
// First time at this concealed item: display one
// character.
if (match_conc)
if (has_match_conc && match_conc)
c = match_conc;
else if (syn_get_sub_char() != NUL)
c = syn_get_sub_char();

View File

@ -4419,9 +4419,8 @@ update_search_hl(
while (cur != NULL || shl_flag == FALSE)
{
if (shl_flag == FALSE
&& ((cur != NULL
&& cur->priority > SEARCH_HL_PRIORITY)
|| cur == NULL))
&& (cur == NULL
|| cur->priority > SEARCH_HL_PRIORITY))
{
shl = search_hl;
shl_flag = TRUE;
@ -4453,7 +4452,7 @@ update_search_hl(
*match_conc = cur->conceal_char;
}
else
*has_match_conc = *match_conc = 0;
*has_match_conc = 0;
# endif
}
else if (col == shl->endcol)
@ -4503,9 +4502,8 @@ update_search_hl(
while (cur != NULL || shl_flag == FALSE)
{
if (shl_flag == FALSE
&& ((cur != NULL
&& cur->priority > SEARCH_HL_PRIORITY)
|| cur == NULL))
&& (cur == NULL ||
cur->priority > SEARCH_HL_PRIORITY))
{
shl = search_hl;
shl_flag = TRUE;

View File

@ -63,9 +63,9 @@ func Test_matchadd_and_conceallevel_3()
setlocal filetype=conf
syntax on
1put='# This is a Test'
" 1234567890123456
let expect = '#ThisisaTest'
1put='# This is a Test $'
" 1234567890123
let expect = '#ThisisaTest$'
call cursor(1, 1)
call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'})
@ -73,22 +73,25 @@ func Test_matchadd_and_conceallevel_3()
let lnum = 2
call assert_equal(expect, Screenline(lnum))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 7))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 10))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 12))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 13))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 14))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 16))
" more matchadd()
" 1234567890123456
let expect = '#Thisisa Test'
" 12345678901234
let expect = '#Thisisa Test$'
call matchadd('ErrorMsg', '\%2l Test', 20, -1, {'conceal': 'X'})
redraw!
call assert_equal(expect, Screenline(lnum))
call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2) , screenattr(lnum, 7))
call assert_equal(screenattr(lnum, 1) , screenattr(lnum, 7))
call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 10))
call assert_equal(screenattr(lnum, 10), screenattr(lnum, 12))
call assert_equal(screenattr(lnum, 10), screenattr(lnum, 13))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 14))
call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 16))
call assert_notequal(screenattr(lnum, 10), screenattr(lnum, 16))
@ -136,15 +139,18 @@ func Test_syn_and_match_conceal()
new
setlocal concealcursor=n conceallevel=1
1put='# This is a Test'
" 1234567890123456
let expect = '#ZThisZisZaZTest'
1put='# This is a Test '
call cursor(1, 1)
call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'})
syntax match MyConceal /\%2l / conceal containedin=ALL cchar=*
redraw!
let lnum = 2
call cursor(1, 1)
" 123456789012345678
let expect = '#ZThisZisZaZTestZZ'
call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'Z'})
syntax match MyConceal /\%2l / conceal containedin=ALL
hi MyConceal ctermbg=4 ctermfg=2
redraw!
call assert_equal(expect, Screenline(lnum))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7))
@ -152,8 +158,19 @@ func Test_syn_and_match_conceal()
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16))
" 1234567890123456
let expect = '#*This*is*a*Test'
syntax clear MyConceal
syntax match MyConceal /\%2l / conceal containedin=ALL cchar=*
redraw!
call assert_equal(expect, Screenline(lnum))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16))
" 123456789012345678
let expect = '#*This*is*a*Test**'
call clearmatches()
redraw!
@ -164,6 +181,48 @@ func Test_syn_and_match_conceal()
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16))
" 123456789012345678
let expect = '#*ThisXis*a*Test**'
call matchadd('Conceal', '\%2l\%7c ', 10, -1, {'conceal': 'X'})
redraw!
call assert_equal(expect, Screenline(lnum))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16))
" 123456789012345678
let expect = '#*ThisXis*a*Test**'
call matchadd('ErrorMsg', '\%2l Test', 20, -1)
redraw!
call assert_equal(expect, Screenline(lnum))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
call assert_notequal(screenattr(lnum, 12), screenattr(lnum, 13))
call assert_equal(screenattr(lnum, 13), screenattr(lnum, 16))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 17))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 18))
call assert_notequal(screenattr(lnum, 18), screenattr(lnum, 19))
" 123456789012345678
let expect = '# ThisXis a Test'
syntax clear MyConceal
syntax match MyConceal /\%2l / conceal containedin=ALL
redraw!
call assert_equal(expect, Screenline(lnum))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 12))
call assert_notequal(screenattr(lnum, 12), screenattr(lnum, 13))
call assert_equal(screenattr(lnum, 13), screenattr(lnum, 16))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 17))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 18))
call assert_notequal(screenattr(lnum, 18), screenattr(lnum, 19))
syntax off
quit!
endfunc

View File

@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1056,
/**/
1055,
/**/