comparison src/testdir/test_matchadd_conceal_utf8.vim @ 8907:5deb9e8f4292 v7.4.1740

commit https://github.com/vim/vim/commit/4d585022023b96f6507e8cae5ed8fc8d926f5140 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 14 19:50:22 2016 +0200 patch 7.4.1740 Problem: syn-cchar defined with matchadd() does not appear if there are no other syntax definitions which matches buffer text. Solution: Check for startcol. (Ozaki Kiichi, haya14busa, closes https://github.com/vim/vim/issues/757)
author Christian Brabandt <cb@256bit.org>
date Thu, 14 Apr 2016 20:00:07 +0200
parents
children 81ba6e4eb72b
comparison
equal deleted inserted replaced
8906:8645ad15934e 8907:5deb9e8f4292
1 " Test for matchadd() and conceal feature using utf-8.
2 if !has('conceal') || !has('multi_byte')
3 finish
4 endif
5 set encoding=utf-8
6 scriptencoding utf-8
7
8 if !has('gui_running') && has('unix')
9 set term=ansi
10 endif
11
12 function! s:screenline(lnum) abort
13 let line = []
14 for c in range(1, winwidth(0))
15 call add(line, nr2char(screenchar(a:lnum, c)))
16 endfor
17 return s:trim(join(line, ''))
18 endfunction
19
20 function! s:trim(str) abort
21 return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$')
22 endfunction
23
24 function! Test_match_using_multibyte_conceal_char()
25 new
26 setlocal concealcursor=n conceallevel=1
27
28 1put='# This is a Test'
29 " 1234567890123456
30 let expect = '#ˑThisˑisˑaˑTest'
31
32 call cursor(1, 1)
33 call matchadd('Conceal', '\%2l ', 20, -1, {'conceal': "\u02d1"})
34 redraw!
35
36 let lnum = 2
37 call assert_equal(expect, s:screenline(lnum))
38 call assert_notequal(screenattr(lnum, 1), screenattr(lnum, 2))
39 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 7))
40 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 10))
41 call assert_equal(screenattr(lnum, 2), screenattr(lnum, 12))
42 call assert_equal(screenattr(lnum, 1), screenattr(lnum, 16))
43
44 quit!
45 endfunction