# HG changeset patch # User Bram Moolenaar # Date 1652041803 -7200 # Node ID a79f44a2d1ce11083a20b9c6f3dad05a271f24a7 # Parent a5c33e82805d0a4f2baa71e6bd9e202b873ce874 patch 8.2.4918: conceal character from matchadd() displayed too many times Commit: https://github.com/vim/vim/commit/9830db63057db76044eca89cc4cfb2758ae7a543 Author: LemonBoy Date: Sun May 8 21:25:20 2022 +0100 patch 8.2.4918: conceal character from matchadd() displayed too many times Problem: Conceal character from matchadd() displayed too many times. Solution: Check the syntax flag. (closes https://github.com/vim/vim/issues/10381, closes https://github.com/vim/vim/issues/7268) diff --git a/src/drawline.c b/src/drawline.c --- a/src/drawline.c +++ b/src/drawline.c @@ -2477,14 +2477,16 @@ win_line( #ifdef FEAT_CONCEAL if ( wp->w_p_cole > 0 - && (wp != curwin || lnum != wp->w_cursor.lnum || - conceal_cursor_line(wp)) + && (wp != curwin || lnum != wp->w_cursor.lnum + || conceal_cursor_line(wp)) && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0) && !(lnum_in_visual_area && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; - if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1) + if (((prev_syntax_id != syntax_seqnr + && (syntax_flags & HL_CONCEAL) != 0) + || has_match_conc > 1) && (syn_get_sub_char() != NUL || (has_match_conc && match_conc) || wp->w_p_cole == 1) diff --git a/src/testdir/test_matchadd_conceal.vim b/src/testdir/test_matchadd_conceal.vim --- a/src/testdir/test_matchadd_conceal.vim +++ b/src/testdir/test_matchadd_conceal.vim @@ -339,6 +339,27 @@ func Test_matchadd_and_syn_conceal() call assert_equal(screenattr(1, 11) , screenattr(1, 32)) endfunc +func Test_interaction_matchadd_syntax() + CheckRunVimInTerminal + + new + " Test for issue #7268 fix. + " When redrawing the second column, win_line() was comparing the sequence + " number of the syntax-concealed region with a bogus zero value that was + " returned for the matchadd-concealed region. Before 8.0.0672 the sequence + " number was never reset, thus masking the problem. + call setline(1, 'aaa|bbb|ccc') + call matchadd('Conceal', '^..', 10, -1, #{conceal: 'X'}) + syn match foobar '^.' + setl concealcursor=n conceallevel=1 + redraw! + + call assert_equal('Xa|bbb|ccc', Screenline(1)) + call assert_notequal(screenattr(1, 1), screenattr(1, 2)) + + bwipe! +endfunc + func Test_cursor_column_in_concealed_line_after_window_scroll() CheckRunVimInTerminal diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4918, +/**/ 4917, /**/ 4916,