test_matchadd_conceal_utf8.vim (1042B)
1 " Test for matchadd() and conceal feature using utf-8. 2 3 source check.vim 4 CheckFeature conceal 5 6 func s:screenline(lnum) abort 7 let line = [] 8 for c in range(1, winwidth(0)) 9 call add(line, nr2char(a:lnum->screenchar(c))) 10 endfor 11 return s:trim(join(line, '')) 12 endfunc 13 14 func s:trim(str) abort 15 return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$') 16 endfunc 17 18 func Test_match_using_multibyte_conceal_char() 19 new 20 setlocal concealcursor=n conceallevel=1 21 22 1put='# This is a Test' 23 " 1234567890123456 24 let expect = '#ˑThisˑisˑaˑTest' 25 26 call cursor(1, 1) 27 call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"}) 28 redraw! 29 30 let lnum = 2 31 call assert_equal(expect, s:screenline(lnum)) 32 call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2)) 33 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7)) 34 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10)) 35 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12)) 36 call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16)) 37 38 quit! 39 endfunc