listlbr_utf8_spec.lua (8017B)
1 -- Test for linebreak and list option in utf-8 mode 2 3 local n = require('test.functional.testnvim')() 4 local Screen = require('test.functional.ui.screen') 5 6 local source = n.source 7 local feed = n.feed 8 local exec = n.exec 9 local clear, expect = n.clear, n.expect 10 11 describe('linebreak', function() 12 before_each(clear) 13 14 -- luacheck: ignore 621 (Indentation) 15 -- luacheck: ignore 613 (Trailing whitespaces in a string) 16 it('is working', function() 17 source([[ 18 set wildchar=^E 19 10new 20 vsp 21 vert resize 20 22 put =\"\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP \" 23 norm! zt 24 set ts=4 sw=4 sts=4 linebreak sbr=+ wrap 25 fu! ScreenChar(width, lines) 26 let c='' 27 for j in range(1,a:lines) 28 for i in range(1,a:width) 29 let c.=nr2char(screenchar(j, i)) 30 endfor 31 let c.="\n" 32 endfor 33 return c 34 endfu 35 fu! DoRecordScreen() 36 wincmd l 37 $put =printf(\"\n%s\", g:test) 38 $put =g:line 39 wincmd p 40 endfu 41 " 42 let g:test ="Test 1: set linebreak + set list + fancy listchars" 43 exe "set linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6" 44 redraw! 45 let line=ScreenChar(winwidth(0),4) 46 call DoRecordScreen() 47 " 48 let g:test ="Test 2: set nolinebreak list" 49 set list nolinebreak 50 redraw! 51 let line=ScreenChar(winwidth(0),4) 52 call DoRecordScreen() 53 " 54 let g:test ="Test 3: set linebreak nolist" 55 $put =\"\t*mask = nil;\" 56 $ 57 norm! zt 58 set nolist linebreak 59 redraw! 60 let line=ScreenChar(winwidth(0),4) 61 call DoRecordScreen() 62 " 63 let g:test ="Test 4: set linebreak list listchars and concealing" 64 let c_defines=['#define ABCDE 1','#define ABCDEF 1','#define ABCDEFG 1','#define ABCDEFGH 1', '#define MSG_MODE_FILE 1','#define MSG_MODE_CONSOLE 2','#define MSG_MODE_FILE_AND_CONSOLE 3','#define MSG_MODE_FILE_THEN_CONSOLE 4'] 65 call append('$', c_defines) 66 vert resize 40 67 $-7 68 norm! zt 69 set list linebreak listchars=tab:>- cole=1 70 syn match Conceal conceal cchar=>'AB\|MSG_MODE' 71 redraw! 72 let line=ScreenChar(winwidth(0),7) 73 call DoRecordScreen() 74 " 75 let g:test ="Test 5: set linebreak list listchars and concealing part2" 76 let c_defines=['bbeeeeee ; some text'] 77 call append('$', c_defines) 78 $ 79 norm! zt 80 set nowrap ts=2 list linebreak listchars=tab:>- cole=2 concealcursor=n 81 syn clear 82 syn match meaning /;\s*\zs.*/ 83 syn match hasword /^\x\{8}/ contains=word 84 syn match word /\<\x\{8}\>/ contains=beginword,endword contained 85 syn match beginword /\<\x\x/ contained conceal 86 syn match endword /\x\{6}\>/ contained 87 hi meaning guibg=blue 88 hi beginword guibg=green 89 hi endword guibg=red 90 redraw! 91 let line=ScreenChar(winwidth(0),1) 92 call DoRecordScreen() 93 " 94 let g:test ="Test 6: Screenattributes for comment" 95 $put =g:test 96 call append('$', ' /* and some more */') 97 exe "set ft=c ts=7 linebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6" 98 syntax on 99 hi SpecialKey term=underline ctermfg=red guifg=red 100 let attr=[] 101 nnoremap <expr> GG ":let attr += ['".screenattr(screenrow(),screencol())."']\n" 102 $ 103 norm! zt0 104 ]]) 105 feed('GGlGGlGGlGGlGGlGGlGGlGGlGGlGGl') 106 source([[ 107 call append('$', ['ScreenAttributes for test6:']) 108 if attr[0] != attr[1] && attr[1] != attr[3] && attr[3] != attr[5] 109 call append('$', "Attribut 0 and 1 and 3 and 5 are different!") 110 else 111 call append('$', "Not all attributes are different") 112 endif 113 set cpo&vim linebreak selection=exclusive 114 let g:test ="Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char" 115 $put =g:test 116 ]]) 117 feed("Golong line: <Esc>40afoobar <Esc>aTARGETÃ' at end<Esc>") 118 source([[ 119 exe "norm! $3B\<C-v>eAx\<Esc>" 120 " 121 let g:test ="Test 9: a multibyte sign and colorcolumn" 122 let attr=[] 123 let attr2=[] 124 $put ='' 125 $put ='a b c' 126 $put ='a b c' 127 set list nolinebreak cc=3 128 ]]) 129 feed(':sign define foo text=<C-v>uff0b<CR>') 130 source([[ 131 sign place 1 name=foo line=50 buffer=2 132 norm! 2kztj 133 let line1=line('.') 134 ]]) 135 feed('0GGlGGlGGlGGl') 136 source([[ 137 let line2=line('.') 138 let attr2=attr 139 let attr=[] 140 ]]) 141 feed('0GGlGGlGGlGGl') 142 source([[ 143 redraw! 144 let line=ScreenChar(winwidth(0),3) 145 call DoRecordScreen() 146 " expected: attr[2] is different because of colorcolumn 147 if attr[0] != attr2[0] || attr[1] != attr2[1] || attr[2] != attr2[2] 148 call append('$', "Screen attributes are different!") 149 else 150 call append('$', "Screen attributes are the same!") 151 endif 152 ]]) 153 154 -- Assert buffer contents. 155 expect([[ 156 157 abcdef hijklmn pqrstuvwxyz 1060ABCDEFGHIJKLMNOP 158 159 Test 1: set linebreak + set list + fancy listchars 160 ▕———abcdef 161 +hijklmn▕——— 162 +pqrstuvwxyz␣1060ABC 163 +DEFGHIJKLMNOPˑ¶ 164 165 Test 2: set nolinebreak list 166 ▕———abcdef hijklmn▕— 167 +pqrstuvwxyz␣1060ABC 168 +DEFGHIJKLMNOPˑ¶ 169 ¶ 170 *mask = nil; 171 172 Test 3: set linebreak nolist 173 *mask = nil; 174 ~ 175 ~ 176 ~ 177 #define ABCDE 1 178 #define ABCDEF 1 179 #define ABCDEFG 1 180 #define ABCDEFGH 1 181 #define MSG_MODE_FILE 1 182 #define MSG_MODE_CONSOLE 2 183 #define MSG_MODE_FILE_AND_CONSOLE 3 184 #define MSG_MODE_FILE_THEN_CONSOLE 4 185 186 Test 4: set linebreak list listchars and concealing 187 #define ABCDE>-->---1 188 #define >CDEF>-->---1 189 #define >CDEFG>->---1 190 #define >CDEFGH>----1 191 #define >_FILE>--------->--->---1 192 #define >_CONSOLE>---------->---2 193 #define >_FILE_AND_CONSOLE>---------3 194 bbeeeeee ; some text 195 196 Test 5: set linebreak list listchars and concealing part2 197 eeeeee>--->-;>some text 198 Test 6: Screenattributes for comment 199 /* and some more */ 200 ScreenAttributes for test6: 201 Attribut 0 and 1 and 3 and 5 are different! 202 Test 8: set linebreak with visual block mode and v_b_A and selection=exclusive and multibyte char 203 long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETÃx' at end 204 205 a b c 206 a b c 207 208 Test 9: a multibyte sign and colorcolumn 209 ¶ 210 +a b c¶ 211 a b c¶ 212 Screen attributes are the same!]]) 213 end) 214 215 -- oldtest: Test_visual_ends_before_showbreak() 216 it("Visual area is correct when it ends before multibyte 'showbreak'", function() 217 local screen = Screen.new(60, 8) 218 exec([[ 219 let &wrap = v:true 220 let &linebreak = v:true 221 let &showbreak = '↪ ' 222 eval ['xxxxx ' .. 'y'->repeat(&columns - 6) .. ' zzzz']->setline(1) 223 normal! wvel 224 ]]) 225 screen:expect([[ 226 xxxxx | 227 {1:↪ }{17:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy}^ {17: }| 228 {1:↪ }zzzz | 229 {1:~ }|*4 230 {5:-- VISUAL --} | 231 ]]) 232 end) 233 end)