Patch 8.2.1056
Problem: Wrong display when mixing match conceal and syntax conceal.
Solution: Adjust how conceal flags are used. (closes #6327, closes #6303)
Files: src/drawline.c, src/highlight.c,
src/testdir/test_matchadd_conceal.vim
*** ../vim-8.2.1055/src/drawline.c 2020-06-18 19:14:58.897637005 +0200
--- src/drawline.c 2020-06-25 20:01:35.588161723 +0200
***************
*** 967,973 ****
for (;;)
{
#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
! int has_match_conc = 0; // match wants to conceal
#endif
#ifdef FEAT_CONCEAL
int did_decrement_ptr = FALSE;
--- 967,973 ----
for (;;)
{
#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
! int has_match_conc = 0; // match wants to conceal
#endif
#ifdef FEAT_CONCEAL
int did_decrement_ptr = FALSE;
***************
*** 2353,2365 ****
{
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)
&& wp->w_p_cole != 3)
{
// First time at this concealed item: display one
// character.
! if (match_conc)
c = match_conc;
else if (syn_get_sub_char() != NUL)
c = syn_get_sub_char();
--- 2353,2366 ----
{
char_attr = conceal_attr;
if ((prev_syntax_id != syntax_seqnr || has_match_conc > 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 (has_match_conc && match_conc)
c = match_conc;
else if (syn_get_sub_char() != NUL)
c = syn_get_sub_char();
*** ../vim-8.2.1055/src/highlight.c 2020-06-12 22:59:07.266097201 +0200
--- src/highlight.c 2020-06-25 20:02:10.416008360 +0200
***************
*** 4419,4427 ****
while (cur != NULL || shl_flag == FALSE)
{
if (shl_flag == FALSE
! && ((cur != NULL
! && cur->priority > SEARCH_HL_PRIORITY)
! || cur == NULL))
{
shl = search_hl;
shl_flag = TRUE;
--- 4419,4426 ----
while (cur != NULL || shl_flag == FALSE)
{
if (shl_flag == FALSE
! && (cur == NULL
! || cur->priority > SEARCH_HL_PRIORITY))
{
shl = search_hl;
shl_flag = TRUE;
***************
*** 4453,4459 ****
*match_conc = cur->conceal_char;
}
else
! *has_match_conc = *match_conc = 0;
# endif
}
else if (col == shl->endcol)
--- 4452,4458 ----
*match_conc = cur->conceal_char;
}
else
! *has_match_conc = 0;
# endif
}
else if (col == shl->endcol)
***************
*** 4503,4511 ****
while (cur != NULL || shl_flag == FALSE)
{
if (shl_flag == FALSE
! && ((cur != NULL
! && cur->priority > SEARCH_HL_PRIORITY)
! || cur == NULL))
{
shl = search_hl;
shl_flag = TRUE;
--- 4502,4509 ----
while (cur != NULL || shl_flag == FALSE)
{
if (shl_flag == FALSE
! && (cur == NULL ||
! cur->priority > SEARCH_HL_PRIORITY))
{
shl = search_hl;
shl_flag = TRUE;
*** ../vim-8.2.1055/src/testdir/test_matchadd_conceal.vim 2020-04-08
21:50:18.876619651 +0200
--- src/testdir/test_matchadd_conceal.vim 2020-06-25 19:56:16.237695788
+0200
***************
*** 63,71 ****
setlocal filetype=conf
syntax on
! 1put='# This is a Test'
! " 1234567890123456
! let expect = '#ThisisaTest'
call cursor(1, 1)
call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'})
--- 63,71 ----
setlocal filetype=conf
syntax on
! 1put='# This is a Test $'
! " 1234567890123
! let expect = '#ThisisaTest$'
call cursor(1, 1)
call matchadd('Conceal', '\%2l ', 10, -1, {'conceal': 'X'})
***************
*** 73,94 ****
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_notequal(screenattr(lnum, 1), screenattr(lnum, 16))
" more matchadd()
! " 1234567890123456
! 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_notequal(screenattr(lnum, 1) , screenattr(lnum, 10))
! call assert_equal(screenattr(lnum, 10), screenattr(lnum, 12))
call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 16))
call assert_notequal(screenattr(lnum, 10), screenattr(lnum, 16))
--- 73,97 ----
let lnum = 2
call assert_equal(expect, Screenline(lnum))
call assert_equal(screenattr(lnum, 1), screenattr(lnum, 2))
! 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()
! " 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, 1) , screenattr(lnum, 7))
call assert_notequal(screenattr(lnum, 1) , screenattr(lnum, 10))
! 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,150 ****
new
setlocal concealcursor=n conceallevel=1
! 1put='# This is a Test'
! " 1234567890123456
! let expect = '#ZThisZisZaZTest'
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 assert_equal(expect, Screenline(lnum))
call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2))
call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7))
--- 139,167 ----
new
setlocal concealcursor=n conceallevel=1
! 1put='# This is a Test '
+ 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))
+ 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))
+
+ 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))
***************
*** 152,159 ****
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'
call clearmatches()
redraw!
--- 169,176 ----
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,169 ****
--- 181,228 ----
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
*** ../vim-8.2.1055/src/version.c 2020-06-25 19:53:21.606571192 +0200
--- src/version.c 2020-06-25 19:58:37.968982455 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1056,
/**/
--
It is illegal for anyone to try and stop a child from playfully jumping over
puddles of water.
[real standing law in California, United States of America]
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202006251807.05PI7epA2284147%40masaka.moolenaar.net.