comparison src/testdir/test_syntax.vim @ 11553:cbceef33af7a v8.0.0659

patch 8.0.0659: no test for conceal mode commit https://github.com/vim/vim/commit/4d785895d1f8b54cdd3fabd87446ca692f49e94e Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 22 22:00:50 2017 +0200 patch 8.0.0659: no test for conceal mode Problem: No test for conceal mode. Solution: Add a conceal mode test. (Dominique Pelle, closes https://github.com/vim/vim/issues/1783)
author Christian Brabandt <cb@256bit.org>
date Thu, 22 Jun 2017 22:15:04 +0200
parents 998d2cf59caa
children 597205f1230e
comparison
equal deleted inserted replaced
11552:d41c3729fd96 11553:cbceef33af7a
1 " Test for syntax and syntax iskeyword option 1 " Test for syntax and syntax iskeyword option
2 2
3 if !has("syntax") 3 if !has("syntax")
4 finish 4 finish
5 endif 5 endif
6
7 source view_util.vim
6 8
7 func GetSyntaxItem(pat) 9 func GetSyntaxItem(pat)
8 let c = '' 10 let c = ''
9 let a = ['a', getreg('a'), getregtype('a')] 11 let a = ['a', getreg('a'), getregtype('a')]
10 0 12 0
456 call assert_true(elapsed < 1.0) 458 call assert_true(elapsed < 1.0)
457 459
458 set redrawtime& 460 set redrawtime&
459 bwipe! 461 bwipe!
460 endfunc 462 endfunc
463
464
465 func Test_conceal()
466 if !has('conceal')
467 return
468 endif
469
470 new
471 call setline(1, ['', '123456'])
472 syn match test23 "23" conceal cchar=X
473 syn match test45 "45" conceal
474
475 set conceallevel=0
476 call assert_equal('123456 ', ScreenLines(2, 7)[0])
477 call assert_equal([[0, ''], [0, ''], [0, ''], [0, ''], [0, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
478
479 set conceallevel=1
480 call assert_equal('1X 6 ', ScreenLines(2, 7)[0])
481 " FIXME: with conceallevel=1, I would expect that the portion "45" of
482 " the line to be replaced with a space since ":help 'conceallevel'
483 " states that if listchars is not set, then the default replacement
484 " should be a space. But synconcealed() gives an empty string in
485 " the 2nd value of the returned list. Bug?
486 " So for now, the following line is commented out:
487 call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, ' '], [1, ' '], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
488
489 set conceallevel=1
490 set listchars=conceal:Y
491 call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, 'Y'], [1, 'Y'], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
492 call assert_equal('1XY6 ', ScreenLines(2, 7)[0])
493
494 set conceallevel=2
495 call assert_match('1X6 ', ScreenLines(2, 7)[0])
496 call assert_equal([[0, ''], [1, 'X'], [1, 'X'], [1, ''], [1, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
497
498 set conceallevel=3
499 call assert_match('16 ', ScreenLines(2, 7)[0])
500 call assert_equal([[0, ''], [1, ''], [1, ''], [1, ''], [1, ''], [0, '']], map(range(1, 6), 'synconcealed(2, v:val)[0:1]'))
501
502 syn clear
503 set conceallevel&
504 bw!
505 endfunc