Patch 8.0.0659
Problem: No test for conceal mode.
Solution: Add a conceal mode test. (Dominique Pelle, closes #1783)
Files: runtime/doc/eval.txt, src/evalfunc.c, src/testdir/test_syntax.vim
*** ../vim-8.0.0658/runtime/doc/eval.txt 2017-06-22 21:29:17.205398557
+0200
--- runtime/doc/eval.txt 2017-06-22 21:56:10.516378889 +0200
***************
*** 7647,7663 ****
":highlight link" are followed.
synconcealed({lnum}, {col}) *synconcealed()*
! The result is a List. The first item in the list is 0 if the
! character at the position {lnum} and {col} is not part of a
! concealable region, 1 if it is. The second item in the list is
! a string. If the first item 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'. 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 .
synstack({lnum}, {col}) *synstack()*
--- 7655,7674 ----
":highlight link" are followed.
synconcealed({lnum}, {col}) *synconcealed()*
! The result is a List with currently three items:
! 1. The first item in the list is 0 if the character at the
! position {lnum} and {col} is not part of a concealable
! region, 1 if it is.
! 2. The second item in the list is a string. If the first item
! 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 .
synstack({lnum}, {col}) *synstack()*
*** ../vim-8.0.0658/src/evalfunc.c 2017-06-17 18:44:17.006000891 +0200
--- src/evalfunc.c 2017-06-22 21:49:30.759602715 +0200
***************
*** 11841,11848 ****
if ((syntax_flags & HL_CONCEAL) && curwin->w_p_cole < 3)
{
cchar = syn_get_sub_char();
! if (cchar == NUL && curwin->w_p_cole == 1 && lcs_conceal != NUL)
! cchar = lcs_conceal;
if (cchar != NUL)
{
# ifdef FEAT_MBYTE
--- 11841,11848 ----
if ((syntax_flags & HL_CONCEAL) && curwin->w_p_cole < 3)
{
cchar = syn_get_sub_char();
! if (cchar == NUL && curwin->w_p_cole == 1)
! cchar = (lcs_conceal == NUL) ? ' ' : lcs_conceal;
if (cchar != NUL)
{
# ifdef FEAT_MBYTE
*** ../vim-8.0.0658/src/testdir/test_syntax.vim 2017-06-18 22:40:36.532444606
+0200
--- src/testdir/test_syntax.vim 2017-06-22 21:49:30.759602715 +0200
***************
*** 4,9 ****
--- 4,11 ----
finish
endif
+ source view_util.vim
+
func GetSyntaxItem(pat)
let c = ''
let a = ['a', getreg('a'), getregtype('a')]
***************
*** 458,460 ****
--- 460,505 ----
set redrawtime&
bwipe!
endfunc
+
+
+ func Test_conceal()
+ if !has('conceal')
+ return
+ endif
+
+ new
+ call setline(1, ['', '123456'])
+ syn match test23 "23" conceal cchar=X
+ syn match test45 "45" 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]'))
+
+ set conceallevel=1
+ call assert_equal('1X 6 ', ScreenLines(2, 7)[0])
+ " FIXME: with conceallevel=1, I would expect that the portion "45" of
+ " the line to be replaced with a space since ":help 'conceallevel'
+ " states that if listchars is not set, then the default replacement
+ " should be a space. But synconcealed() gives an empty string in
+ " the 2nd value of the returned list. Bug?
+ " So for now, the following line is commented out:
+ call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, ' '], [1, ' '], [0,
'']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
+
+ 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('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]'))
+
+ 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]'))
+
+ syn clear
+ set conceallevel&
+ bw!
+ endfunc
*** ../vim-8.0.0658/src/version.c 2017-06-22 21:42:43.794885033 +0200
--- src/version.c 2017-06-22 21:50:50.550958982 +0200
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 659,
/**/
--
hundred-and-one symptoms of being an internet addict:
63. You start using smileys in your snail mail.
/// 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].
For more options, visit https://groups.google.com/d/optout.