vim-patch:8.0.0672: synconcealed() changes too often #7887

Problem:    Third item of synconcealed() changes too often. (Dominique Pelle)
Solution:   Reset the sequence number at the start of each line.
cc0750dc6e

closes #7589
This commit is contained in:
nate 2017-12-04 07:36:03 -08:00 committed by Justin M. Keyes
parent 3a5721e91b
commit dfcd09dc22
4 changed files with 25 additions and 13 deletions

View File

@ -7610,12 +7610,21 @@ synconcealed({lnum}, {col}) *synconcealed()*
is 1, the second item contains the text which will be
displayed in place of the concealed text, depending on the
current setting of 'conceallevel' and 'listchars'.
3. The third and final item in the list is a unique number
representing the specific syntax region matched. This
allows detection of the beginning of a new concealable
region if there are two consecutive regions with the same
replacement character. For an example use see
$VIMRUNTIME/syntax/2html.vim .
3. The third and final item in the list is a number
representing the specific syntax region matched in the
line. When the character is not concealed the value is
zero. This allows detection of the beginning of a new
concealable region if there are two consecutive regions
with the same replacement character. For an example, if
the text is "123456" and both "23" and "45" are concealed
and replace by the character "X", then:
call returns ~
synconcealed(lnum, 1) [0, '', 0]
synconcealed(lnum, 2) [1, 'X', 1]
synconcealed(lnum, 3) [1, 'X', 1]
synconcealed(lnum, 4) [1, 'X', 2]
synconcealed(lnum, 5) [1, 'X', 2]
synconcealed(lnum, 6) [0, '', 0]
synstack({lnum}, {col}) *synstack()*

View File

@ -881,7 +881,8 @@ static void syn_start_line(void)
}
next_match_idx = -1;
++current_line_id;
current_line_id++;
next_seqnr = 1;
}
/*
@ -1599,6 +1600,7 @@ get_syntax_attr (
current_id = 0;
current_trans_id = 0;
current_flags = 0;
current_seqnr = 0;
return 0;
}
@ -2042,6 +2044,7 @@ syn_current_attr (
current_id = 0;
current_trans_id = 0;
current_flags = 0;
current_seqnr = 0;
if (cur_si != NULL) {
for (int idx = current_state.ga_len - 1; idx >= 0; --idx) {
sip = &CUR_STATE(idx);

View File

@ -356,24 +356,24 @@ func Test_conceal()
set conceallevel=0
call assert_equal('123456 ', ScreenLines(2, 7)[0])
call assert_equal([[0, ''], [0, ''], [0, ''], [0, ''], [0, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
call assert_equal([[0, '', 0], [0, '', 0], [0, '', 0], [0, '', 0], [0, '', 0], [0, '', 0]], map(range(1, 6), 'synconcealed(2, v:val)'))
set conceallevel=1
call assert_equal('1X 6 ', ScreenLines(2, 7)[0])
call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, ' '], [1, ' '], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
call assert_equal([[0, '', 0], [1, 'X', 1], [1, 'X', 1], [1, ' ', 2], [1, ' ', 2], [0, '', 0]], map(range(1, 6), 'synconcealed(2, v:val)'))
set conceallevel=1
set listchars=conceal:Y
call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, 'Y'], [1, 'Y'], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
call assert_equal([[0, '', 0], [1, 'X', 1], [1, 'X', 1], [1, 'Y', 2], [1, 'Y', 2], [0, '', 0]], map(range(1, 6), 'synconcealed(2, v:val)'))
call assert_equal('1XY6 ', ScreenLines(2, 7)[0])
set conceallevel=2
call assert_match('1X6 ', ScreenLines(2, 7)[0])
call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, ''], [1, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
call assert_equal([[0, '', 0], [1, 'X', 1], [1, 'X', 1], [1, '', 2], [1, '', 2], [0, '', 0]], map(range(1, 6), 'synconcealed(2, v:val)'))
set conceallevel=3
call assert_match('16 ', ScreenLines(2, 7)[0])
call assert_equal([[0, ''], [1, ''], [1, ''], [1, ''], [1, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
call assert_equal([[0, '', 0], [1, '', 1], [1, '', 1], [1, '', 2], [1, '', 2], [0, '', 0]], map(range(1, 6), 'synconcealed(2, v:val)'))
syn clear
set conceallevel&

View File

@ -825,7 +825,7 @@ static const int included_patches[] = {
// 675,
// 674,
// 673,
// 672,
672,
// 671,
// 670,
// 669,