summaryrefslogtreecommitdiff
path: root/src/testdir/test_syntax.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-22 22:00:50 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-22 22:00:50 +0200
commit4d785895d1f8b54cdd3fabd87446ca692f49e94e (patch)
treed542ce7d05e2d7875f2d2523bbd16281cd0ca830 /src/testdir/test_syntax.vim
parentd2c061d24c0534f1f1b92f3462ed6ae8fa848a9a (diff)
downloadvim-git-4d785895d1f8b54cdd3fabd87446ca692f49e94e.tar.gz
patch 8.0.0659: no test for conceal modev8.0.0659
Problem: No test for conceal mode. Solution: Add a conceal mode test. (Dominique Pelle, closes #1783)
Diffstat (limited to 'src/testdir/test_syntax.vim')
-rw-r--r--src/testdir/test_syntax.vim45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim
index 427ed7b4f..0b1b4e46b 100644
--- a/src/testdir/test_syntax.vim
+++ b/src/testdir/test_syntax.vim
@@ -4,6 +4,8 @@ if !has("syntax")
finish
endif
+source view_util.vim
+
func GetSyntaxItem(pat)
let c = ''
let a = ['a', getreg('a'), getregtype('a')]
@@ -458,3 +460,46 @@ func Test_syntax_hangs()
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