Skip to content

Commit 41ce7b0

Browse files
authored
Merge pull request neovim#18490 from zeertzjq/vim-8.2.4918
vim-patch:8.2.{4918,4923}: conceal character from matchadd() displayed too many times
2 parents 5382ed8 + 79929cf commit 41ce7b0

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/nvim/screen.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,13 +3666,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
36663666
}
36673667

36683668
if (wp->w_p_cole > 0
3669-
&& (wp != curwin || lnum != wp->w_cursor.lnum
3670-
|| conceal_cursor_line(wp))
3669+
&& (wp != curwin || lnum != wp->w_cursor.lnum || conceal_cursor_line(wp))
36713670
&& ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0 || decor_conceal > 0)
3672-
&& !(lnum_in_visual_area
3673-
&& vim_strchr(wp->w_p_cocu, 'v') == NULL)) {
3671+
&& !(lnum_in_visual_area && vim_strchr(wp->w_p_cocu, 'v') == NULL)) {
36743672
char_attr = conceal_attr;
3675-
if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1 || decor_conceal > 1)
3673+
if (((prev_syntax_id != syntax_seqnr && (syntax_flags & HL_CONCEAL) != 0)
3674+
|| has_match_conc > 1 || decor_conceal > 1)
36763675
&& (syn_get_sub_char() != NUL
36773676
|| (has_match_conc && match_conc)
36783677
|| (decor_conceal && decor_state.conceal_char)

src/nvim/testdir/test_matchadd_conceal.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,25 @@ func Test_matchadd_and_syn_conceal()
335335
call assert_equal(screenattr(1, 11) , screenattr(1, 32))
336336
endfunc
337337

338+
func Test_interaction_matchadd_syntax()
339+
new
340+
" Test for issue #7268 fix.
341+
" When redrawing the second column, win_line() was comparing the sequence
342+
" number of the syntax-concealed region with a bogus zero value that was
343+
" returned for the matchadd-concealed region. Before 8.0.0672 the sequence
344+
" number was never reset, thus masking the problem.
345+
call setline(1, 'aaa|bbb|ccc')
346+
call matchadd('Conceal', '^..', 10, -1, #{conceal: 'X'})
347+
syn match foobar '^.'
348+
setl concealcursor=n conceallevel=1
349+
redraw!
350+
351+
call assert_equal('Xa|bbb|ccc', Screenline(1))
352+
call assert_notequal(screenattr(1, 1), screenattr(1, 2))
353+
354+
bwipe!
355+
endfunc
356+
338357
func Test_cursor_column_in_concealed_line_after_window_scroll()
339358
CheckRunVimInTerminal
340359

0 commit comments

Comments
 (0)