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