1" Tests for ":highlight" and highlighting.
2
3source view_util.vim
4source screendump.vim
5source check.vim
6
7func Test_highlight()
8  " basic test if ":highlight" doesn't crash
9  highlight
10  hi Search
11
12  " test setting colors.
13  " test clearing one color and all doesn't generate error or warning
14  silent! hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan
15  silent! hi Group2 term= cterm=
16  hi Group3 term=underline cterm=bold
17
18  let res = split(execute("hi NewGroup"), "\n")[0]
19  " filter ctermfg and ctermbg, the numbers depend on the terminal
20  let res = substitute(res, 'ctermfg=\d*', 'ctermfg=2', '')
21  let res = substitute(res, 'ctermbg=\d*', 'ctermbg=3', '')
22  call assert_equal("NewGroup       xxx term=bold cterm=italic ctermfg=2 ctermbg=3",
23				\ res)
24  call assert_equal("Group2         xxx cleared",
25				\ split(execute("hi Group2"), "\n")[0])
26  call assert_equal("Group3         xxx term=underline cterm=bold",
27				\ split(execute("hi Group3"), "\n")[0])
28
29  hi clear NewGroup
30  call assert_equal("NewGroup       xxx cleared",
31				\ split(execute("hi NewGroup"), "\n")[0])
32  call assert_equal("Group2         xxx cleared",
33				\ split(execute("hi Group2"), "\n")[0])
34  hi Group2 NONE
35  call assert_equal("Group2         xxx cleared",
36				\ split(execute("hi Group2"), "\n")[0])
37  hi clear
38  call assert_equal("Group3         xxx cleared",
39				\ split(execute("hi Group3"), "\n")[0])
40  call assert_fails("hi Crash term='asdf", "E475:")
41endfunc
42
43func HighlightArgs(name)
44  return 'hi ' . substitute(split(execute('hi ' . a:name), '\n')[0], '\<xxx\>', '', '')
45endfunc
46
47func IsColorable()
48  return has('gui_running') || str2nr(&t_Co) >= 8
49endfunc
50
51func HiCursorLine()
52  let hiCursorLine = HighlightArgs('CursorLine')
53  if has('gui_running')
54    let guibg = matchstr(hiCursorLine, 'guibg=\w\+')
55    let hi_ul = 'hi CursorLine gui=underline guibg=NONE'
56    let hi_bg = 'hi CursorLine gui=NONE ' . guibg
57  else
58    let hi_ul = 'hi CursorLine cterm=underline ctermbg=NONE'
59    let hi_bg = 'hi CursorLine cterm=NONE ctermbg=Gray'
60  endif
61  return [hiCursorLine, hi_ul, hi_bg]
62endfunc
63
64func Check_lcs_eol_attrs(attrs, row, col)
65  let save_lcs = &lcs
66  set list
67
68  call assert_equal(a:attrs, ScreenAttrs(a:row, a:col)[0])
69
70  set nolist
71  let &lcs = save_lcs
72endfunc
73
74func Test_highlight_eol_with_cursorline()
75  let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine()
76
77  call NewWindow('topleft 5', 20)
78  call setline(1, 'abcd')
79  call matchadd('Search', '\n')
80
81  " expected:
82  " 'abcd      '
83  "  ^^^^ ^^^^^   no highlight
84  "      ^        'Search' highlight
85  let attrs0 = ScreenAttrs(1, 10)[0]
86  call assert_equal(repeat([attrs0[0]], 4), attrs0[0:3])
87  call assert_equal(repeat([attrs0[0]], 5), attrs0[5:9])
88  call assert_notequal(attrs0[0], attrs0[4])
89
90  setlocal cursorline
91
92  " underline
93  exe hi_ul
94
95  " expected:
96  " 'abcd      '
97  "  ^^^^         underline
98  "      ^        'Search' highlight with underline
99  "       ^^^^^   underline
100  let attrs = ScreenAttrs(1, 10)[0]
101  call assert_equal(repeat([attrs[0]], 4), attrs[0:3])
102  call assert_equal([attrs[4]] + repeat([attrs[5]], 5), attrs[4:9])
103  call assert_notequal(attrs[0], attrs[4])
104  call assert_notequal(attrs[4], attrs[5])
105  call assert_notequal(attrs0[0], attrs[0])
106  call assert_notequal(attrs0[4], attrs[4])
107  call Check_lcs_eol_attrs(attrs, 1, 10)
108
109  if IsColorable()
110    " bg-color
111    exe hi_bg
112
113    " expected:
114    " 'abcd      '
115    "  ^^^^         bg-color of 'CursorLine'
116    "      ^        'Search' highlight
117    "       ^^^^^   bg-color of 'CursorLine'
118    let attrs = ScreenAttrs(1, 10)[0]
119    call assert_equal(repeat([attrs[0]], 4), attrs[0:3])
120    call assert_equal(repeat([attrs[5]], 5), attrs[5:9])
121    call assert_equal(attrs0[4], attrs[4])
122    call assert_notequal(attrs[0], attrs[4])
123    call assert_notequal(attrs[4], attrs[5])
124    call assert_notequal(attrs0[0], attrs[0])
125    call assert_notequal(attrs0[5], attrs[5])
126    call Check_lcs_eol_attrs(attrs, 1, 10)
127  endif
128
129  call CloseWindow()
130  exe hiCursorLine
131endfunc
132
133func Test_highlight_eol_with_cursorline_vertsplit()
134  let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine()
135
136  call NewWindow('topleft 5', 5)
137  call setline(1, 'abcd')
138  call matchadd('Search', '\n')
139
140  let expected = "abcd |abcd     "
141  let actual = ScreenLines(1, 15)[0]
142  call assert_equal(expected, actual)
143
144  " expected:
145  " 'abcd |abcd     '
146  "  ^^^^  ^^^^^^^^^   no highlight
147  "      ^             'Search' highlight
148  "       ^            'VertSplit' highlight
149  let attrs0 = ScreenAttrs(1, 15)[0]
150  call assert_equal(repeat([attrs0[0]], 4), attrs0[0:3])
151  call assert_equal(repeat([attrs0[0]], 9), attrs0[6:14])
152  call assert_notequal(attrs0[0], attrs0[4])
153  call assert_notequal(attrs0[0], attrs0[5])
154  call assert_notequal(attrs0[4], attrs0[5])
155
156  setlocal cursorline
157
158  " expected:
159  " 'abcd |abcd     '
160  "  ^^^^              underline
161  "      ^             'Search' highlight with underline
162  "       ^            'VertSplit' highlight
163  "        ^^^^^^^^^   no highlight
164
165  " underline
166  exe hi_ul
167
168  let actual = ScreenLines(1, 15)[0]
169  call assert_equal(expected, actual)
170
171  let attrs = ScreenAttrs(1, 15)[0]
172  call assert_equal(repeat([attrs[0]], 4), attrs[0:3])
173  call assert_equal(repeat([attrs[6]], 9), attrs[6:14])
174  call assert_equal(attrs0[5:14], attrs[5:14])
175  call assert_notequal(attrs[0], attrs[4])
176  call assert_notequal(attrs[0], attrs[5])
177  call assert_notequal(attrs[0], attrs[6])
178  call assert_notequal(attrs[4], attrs[5])
179  call assert_notequal(attrs[5], attrs[6])
180  call assert_notequal(attrs0[0], attrs[0])
181  call assert_notequal(attrs0[4], attrs[4])
182  call Check_lcs_eol_attrs(attrs, 1, 15)
183
184  if IsColorable()
185    " bg-color
186    exe hi_bg
187
188    let actual = ScreenLines(1, 15)[0]
189    call assert_equal(expected, actual)
190
191    let attrs = ScreenAttrs(1, 15)[0]
192    call assert_equal(repeat([attrs[0]], 4), attrs[0:3])
193    call assert_equal(repeat([attrs[6]], 9), attrs[6:14])
194    call assert_equal(attrs0[5:14], attrs[5:14])
195    call assert_notequal(attrs[0], attrs[4])
196    call assert_notequal(attrs[0], attrs[5])
197    call assert_notequal(attrs[0], attrs[6])
198    call assert_notequal(attrs[4], attrs[5])
199    call assert_notequal(attrs[5], attrs[6])
200    call assert_notequal(attrs0[0], attrs[0])
201    call assert_equal(attrs0[4], attrs[4])
202    call Check_lcs_eol_attrs(attrs, 1, 15)
203  endif
204
205  call CloseWindow()
206  exe hiCursorLine
207endfunc
208
209func Test_highlight_eol_with_cursorline_rightleft()
210  if !has('rightleft')
211    return
212  endif
213
214  let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine()
215
216  call NewWindow('topleft 5', 10)
217  setlocal rightleft
218  call setline(1, 'abcd')
219  call matchadd('Search', '\n')
220  let attrs0 = ScreenAttrs(1, 10)[0]
221
222  setlocal cursorline
223
224  " underline
225  exe hi_ul
226
227  " expected:
228  " '      dcba'
229  "        ^^^^   underline
230  "       ^       'Search' highlight with underline
231  "  ^^^^^        underline
232  let attrs = ScreenAttrs(1, 10)[0]
233  call assert_equal(repeat([attrs[9]], 4), attrs[6:9])
234  call assert_equal(repeat([attrs[4]], 5) + [attrs[5]], attrs[0:5])
235  call assert_notequal(attrs[9], attrs[5])
236  call assert_notequal(attrs[4], attrs[5])
237  call assert_notequal(attrs0[9], attrs[9])
238  call assert_notequal(attrs0[5], attrs[5])
239  call Check_lcs_eol_attrs(attrs, 1, 10)
240
241  if IsColorable()
242    " bg-color
243    exe hi_bg
244
245    " expected:
246    " '      dcba'
247    "        ^^^^   bg-color of 'CursorLine'
248    "       ^       'Search' highlight
249    "  ^^^^^        bg-color of 'CursorLine'
250    let attrs = ScreenAttrs(1, 10)[0]
251    call assert_equal(repeat([attrs[9]], 4), attrs[6:9])
252    call assert_equal(repeat([attrs[4]], 5), attrs[0:4])
253    call assert_equal(attrs0[5], attrs[5])
254    call assert_notequal(attrs[9], attrs[5])
255    call assert_notequal(attrs[5], attrs[4])
256    call assert_notequal(attrs0[9], attrs[9])
257    call assert_notequal(attrs0[4], attrs[4])
258    call Check_lcs_eol_attrs(attrs, 1, 10)
259  endif
260
261  call CloseWindow()
262  exe hiCursorLine
263endfunc
264
265func Test_highlight_eol_with_cursorline_linewrap()
266  let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine()
267
268  call NewWindow('topleft 5', 10)
269  call setline(1, [repeat('a', 51) . 'bcd', ''])
270  call matchadd('Search', '\n')
271
272  setlocal wrap
273  normal! gg$
274  let attrs0 = ScreenAttrs(5, 10)[0]
275  setlocal cursorline
276
277  " underline
278  exe hi_ul
279
280  " expected:
281  " 'abcd      '
282  "  ^^^^         underline
283  "      ^        'Search' highlight with underline
284  "       ^^^^^   underline
285  let attrs = ScreenAttrs(5, 10)[0]
286  call assert_equal(repeat([attrs[0]], 4), attrs[0:3])
287  call assert_equal([attrs[4]] + repeat([attrs[5]], 5), attrs[4:9])
288  call assert_notequal(attrs[0], attrs[4])
289  call assert_notequal(attrs[4], attrs[5])
290  call assert_notequal(attrs0[0], attrs[0])
291  call assert_notequal(attrs0[4], attrs[4])
292  call Check_lcs_eol_attrs(attrs, 5, 10)
293
294  if IsColorable()
295    " bg-color
296    exe hi_bg
297
298    " expected:
299    " 'abcd      '
300    "  ^^^^         bg-color of 'CursorLine'
301    "      ^        'Search' highlight
302    "       ^^^^^   bg-color of 'CursorLine'
303    let attrs = ScreenAttrs(5, 10)[0]
304    call assert_equal(repeat([attrs[0]], 4), attrs[0:3])
305    call assert_equal(repeat([attrs[5]], 5), attrs[5:9])
306    call assert_equal(attrs0[4], attrs[4])
307    call assert_notequal(attrs[0], attrs[4])
308    call assert_notequal(attrs[4], attrs[5])
309    call assert_notequal(attrs0[0], attrs[0])
310    call assert_notequal(attrs0[5], attrs[5])
311    call Check_lcs_eol_attrs(attrs, 5, 10)
312  endif
313
314  setlocal nocursorline nowrap
315  normal! gg$
316  let attrs0 = ScreenAttrs(1, 10)[0]
317  setlocal cursorline
318
319  " underline
320  exe hi_ul
321
322  " expected:
323  " 'aaabcd    '
324  "  ^^^^^^       underline
325  "        ^      'Search' highlight with underline
326  "         ^^^   underline
327  let attrs = ScreenAttrs(1, 10)[0]
328  call assert_equal(repeat([attrs[0]], 6), attrs[0:5])
329  call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9])
330  call assert_notequal(attrs[0], attrs[6])
331  call assert_notequal(attrs[6], attrs[7])
332  call assert_notequal(attrs0[0], attrs[0])
333  call assert_notequal(attrs0[6], attrs[6])
334  call Check_lcs_eol_attrs(attrs, 1, 10)
335
336  if IsColorable()
337    " bg-color
338    exe hi_bg
339
340    " expected:
341    " 'aaabcd    '
342    "  ^^^^^^       bg-color of 'CursorLine'
343    "        ^      'Search' highlight
344    "         ^^^   bg-color of 'CursorLine'
345    let attrs = ScreenAttrs(1, 10)[0]
346    call assert_equal(repeat([attrs[0]], 6), attrs[0:5])
347    call assert_equal(repeat([attrs[7]], 3), attrs[7:9])
348    call assert_equal(attrs0[6], attrs[6])
349    call assert_notequal(attrs[0], attrs[6])
350    call assert_notequal(attrs[6], attrs[7])
351    call assert_notequal(attrs0[0], attrs[0])
352    call assert_notequal(attrs0[7], attrs[7])
353    call Check_lcs_eol_attrs(attrs, 1, 10)
354  endif
355
356  call CloseWindow()
357  exe hiCursorLine
358endfunc
359
360func Test_highlight_eol_with_cursorline_sign()
361  if !has('signs')
362    return
363  endif
364
365  let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine()
366
367  call NewWindow('topleft 5', 10)
368  call setline(1, 'abcd')
369  call matchadd('Search', '\n')
370
371  sign define Sign text=>>
372  exe 'sign place 1 line=1 name=Sign buffer=' . bufnr('')
373  let attrs0 = ScreenAttrs(1, 10)[0]
374  setlocal cursorline
375
376  " underline
377  exe hi_ul
378
379  " expected:
380  " '>>abcd    '
381  "  ^^           sign
382  "    ^^^^       underline
383  "        ^      'Search' highlight with underline
384  "         ^^^   underline
385  let attrs = ScreenAttrs(1, 10)[0]
386  call assert_equal(repeat([attrs[2]], 4), attrs[2:5])
387  call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9])
388  call assert_notequal(attrs[2], attrs[6])
389  call assert_notequal(attrs[6], attrs[7])
390  call assert_notequal(attrs0[2], attrs[2])
391  call assert_notequal(attrs0[6], attrs[6])
392  call Check_lcs_eol_attrs(attrs, 1, 10)
393
394  if IsColorable()
395    " bg-color
396    exe hi_bg
397
398    " expected:
399    " '>>abcd    '
400    "  ^^           sign
401    "    ^^^^       bg-color of 'CursorLine'
402    "        ^      'Search' highlight
403    "         ^^^   bg-color of 'CursorLine'
404    let attrs = ScreenAttrs(1, 10)[0]
405    call assert_equal(repeat([attrs[2]], 4), attrs[2:5])
406    call assert_equal(repeat([attrs[7]], 3), attrs[7:9])
407    call assert_equal(attrs0[6], attrs[6])
408    call assert_notequal(attrs[2], attrs[6])
409    call assert_notequal(attrs[6], attrs[7])
410    call assert_notequal(attrs0[2], attrs[2])
411    call assert_notequal(attrs0[7], attrs[7])
412    call Check_lcs_eol_attrs(attrs, 1, 10)
413  endif
414
415  sign unplace 1
416  call CloseWindow()
417  exe hiCursorLine
418endfunc
419
420func Test_highlight_eol_with_cursorline_breakindent()
421  if !has('linebreak')
422    return
423  endif
424
425  let [hiCursorLine, hi_ul, hi_bg] = HiCursorLine()
426
427  call NewWindow('topleft 5', 10)
428  set showbreak=xxx
429  setlocal breakindent breakindentopt=min:0,shift:1 showbreak=>
430  call setline(1, ' ' . repeat('a', 9) . 'bcd')
431  call matchadd('Search', '\n')
432  let attrs0 = ScreenAttrs(2, 10)[0]
433  setlocal cursorline
434
435  " underline
436  exe hi_ul
437
438  " expected:
439  " '  >bcd    '
440  "  ^^^          breakindent and showbreak
441  "     ^^^       underline
442  "        ^      'Search' highlight with underline
443  "         ^^^   underline
444  let attrs = ScreenAttrs(2, 10)[0]
445  call assert_equal(repeat([attrs[0]], 2), attrs[0:1])
446  call assert_equal(repeat([attrs[3]], 3), attrs[3:5])
447  call assert_equal([attrs[6]] + repeat([attrs[7]], 3), attrs[6:9])
448  call assert_equal(attrs0[0], attrs[0])
449  call assert_notequal(attrs[0], attrs[2])
450  call assert_notequal(attrs[2], attrs[3])
451  call assert_notequal(attrs[3], attrs[6])
452  call assert_notequal(attrs[6], attrs[7])
453  call assert_notequal(attrs0[2], attrs[2])
454  call assert_notequal(attrs0[3], attrs[3])
455  call assert_notequal(attrs0[6], attrs[6])
456  call Check_lcs_eol_attrs(attrs, 2, 10)
457
458  if IsColorable()
459    " bg-color
460    exe hi_bg
461
462    " expected:
463    " '  >bcd    '
464    "  ^^^          breakindent and showbreak
465    "     ^^^       bg-color of 'CursorLine'
466    "        ^      'Search' highlight
467    "         ^^^   bg-color of 'CursorLine'
468    let attrs = ScreenAttrs(2, 10)[0]
469    call assert_equal(repeat([attrs[0]], 2), attrs[0:1])
470    call assert_equal(repeat([attrs[3]], 3), attrs[3:5])
471    call assert_equal(repeat([attrs[7]], 3), attrs[7:9])
472    call assert_equal(attrs0[0], attrs[0])
473    call assert_equal(attrs0[6], attrs[6])
474    call assert_notequal(attrs[0], attrs[2])
475    call assert_notequal(attrs[2], attrs[3])
476    call assert_notequal(attrs[3], attrs[6])
477    call assert_notequal(attrs[6], attrs[7])
478    call assert_notequal(attrs0[2], attrs[2])
479    call assert_notequal(attrs0[3], attrs[3])
480    call assert_notequal(attrs0[7], attrs[7])
481    call Check_lcs_eol_attrs(attrs, 2, 10)
482  endif
483
484  call CloseWindow()
485  set showbreak=
486  setlocal showbreak=
487  exe hiCursorLine
488endfunc
489
490func Test_highlight_eol_on_diff()
491  call setline(1, ['abcd', ''])
492  call matchadd('Search', '\n')
493  let attrs0 = ScreenAttrs(1, 10)[0]
494
495  diffthis
496  botright new
497  diffthis
498
499  " expected:
500  " '  abcd    '
501  "  ^^           sign
502  "    ^^^^ ^^^   'DiffAdd' highlight
503  "        ^      'Search' highlight
504  let attrs = ScreenAttrs(1, 10)[0]
505  call assert_equal(repeat([attrs[0]], 2), attrs[0:1])
506  call assert_equal(repeat([attrs[2]], 4), attrs[2:5])
507  call assert_equal(repeat([attrs[2]], 3), attrs[7:9])
508  call assert_equal(attrs0[4], attrs[6])
509  call assert_notequal(attrs[0], attrs[2])
510  call assert_notequal(attrs[0], attrs[6])
511  call assert_notequal(attrs[2], attrs[6])
512  call Check_lcs_eol_attrs(attrs, 1, 10)
513
514  bwipe!
515  diffoff
516endfunc
517
518func Test_termguicolors()
519  if !exists('+termguicolors')
520    return
521  endif
522  if has('vtp') && !has('vcon') && !has('gui_running')
523    " Win32: 'guicolors' doesn't work without virtual console.
524    call assert_fails('set termguicolors', 'E954:')
525    return
526  endif
527
528  " Basic test that setting 'termguicolors' works with one color.
529  set termguicolors
530  redraw
531  set t_Co=1
532  redraw
533  set t_Co=0
534  redraw
535endfunc
536
537func Test_cursorline_after_yank()
538  CheckScreendump
539
540  call writefile([
541	\ 'set cul rnu',
542	\ 'call setline(1, ["","1","2","3",""])',
543	\ ], 'Xtest_cursorline_yank')
544  let buf = RunVimInTerminal('-S Xtest_cursorline_yank', {'rows': 8})
545  call term_wait(buf)
546  call term_sendkeys(buf, "Gy3k")
547  call term_wait(buf)
548  call term_sendkeys(buf, "jj")
549
550  call VerifyScreenDump(buf, 'Test_cursorline_yank_01', {})
551
552  " clean up
553  call StopVimInTerminal(buf)
554  call delete('Xtest_cursorline_yank')
555endfunc
556
557" test for issue #4862
558func Test_put_before_cursorline()
559  new
560  only!
561  call setline(1, 'A')
562  redraw
563  let std_attr = screenattr(1, 1)
564  set cursorline
565  redraw
566  let cul_attr = screenattr(1, 1)
567  normal yyP
568  redraw
569  " Line 1 has cursor so it should be highlighted with CursorLine.
570  call assert_equal(cul_attr, screenattr(1, 1))
571  " And CursorLine highlighting from the second line should be gone.
572  call assert_equal(std_attr, screenattr(2, 1))
573  set nocursorline
574  bwipe!
575endfunc
576
577func Test_cursorline_with_visualmode()
578  CheckScreendump
579
580  call writefile([
581	\ 'set cul',
582	\ 'call setline(1, repeat(["abc"], 50))',
583	\ ], 'Xtest_cursorline_with_visualmode')
584  let buf = RunVimInTerminal('-S Xtest_cursorline_with_visualmode', {'rows': 12})
585  call term_wait(buf)
586  call term_sendkeys(buf, "V\<C-f>kkkjk")
587
588  call VerifyScreenDump(buf, 'Test_cursorline_with_visualmode_01', {})
589
590  " clean up
591  call StopVimInTerminal(buf)
592  call delete('Xtest_cursorline_with_visualmode')
593endfunc
594
595func Test_wincolor()
596  CheckScreendump
597  " make sure the width is enough for the test
598  set columns=80
599
600  let lines =<< trim END
601	set cursorline cursorcolumn rnu
602	call setline(1, ["","1111111111","22222222222","3 here 3","","the cat is out of the bag"])
603	set wincolor=Pmenu
604	hi CatLine guifg=green ctermfg=green
605	hi Reverse gui=reverse cterm=reverse
606	syn match CatLine /^the.*/
607	call prop_type_add("foo", {"highlight": "Reverse", "combine": 1})
608	call prop_add(6, 12, {"type": "foo", "end_col": 15})
609	/here
610  END
611  call writefile(lines, 'Xtest_wincolor')
612  let buf = RunVimInTerminal('-S Xtest_wincolor', {'rows': 8})
613  call term_wait(buf)
614  call term_sendkeys(buf, "2G5lvj")
615  call term_wait(buf)
616
617  call VerifyScreenDump(buf, 'Test_wincolor_01', {})
618
619  " clean up
620  call term_sendkeys(buf, "\<Esc>")
621  call StopVimInTerminal(buf)
622  call delete('Xtest_wincolor')
623endfunc
624
625func Test_wincolor_listchars()
626  CheckScreendump
627  CheckFeature conceal
628
629  let lines =<< trim END
630	call setline(1, ["one","\t\tsome random text enough long to show 'extends' and 'precedes' includingnbsps, preceding tabs and trailing spaces    ","three"])
631	set wincolor=Todo
632	set nowrap cole=1 cocu+=n
633	set list lcs=eol:$,tab:>-,space:.,trail:_,extends:>,precedes:<,conceal:*,nbsp:#
634	call matchadd('Conceal', 'text')
635	normal 2G5zl
636  END
637  call writefile(lines, 'Xtest_wincolorlcs')
638  let buf = RunVimInTerminal('-S Xtest_wincolorlcs', {'rows': 8})
639
640  call VerifyScreenDump(buf, 'Test_wincolor_lcs', {})
641
642  " clean up
643  call term_sendkeys(buf, "\<Esc>")
644  call StopVimInTerminal(buf)
645  call delete('Xtest_wincolorlcs')
646endfunc
647
648func Test_colorcolumn()
649  CheckScreendump
650
651  " check that setting 'colorcolumn' when entering a buffer works
652  let lines =<< trim END
653	split
654	edit X
655	call setline(1, ["1111111111","22222222222","3333333333"])
656	set nomodified
657	set colorcolumn=3,9
658	set number cursorline cursorlineopt=number
659	wincmd w
660	buf X
661  END
662  call writefile(lines, 'Xtest_colorcolumn')
663  let buf = RunVimInTerminal('-S Xtest_colorcolumn', {'rows': 10})
664  call term_sendkeys(buf, ":\<CR>")
665  call term_wait(buf)
666  call VerifyScreenDump(buf, 'Test_colorcolumn_1', {})
667
668  " clean up
669  call StopVimInTerminal(buf)
670  call delete('Xtest_colorcolumn')
671endfunc
672
673" This test must come before the Test_cursorline test, as it appears this
674" defines the Normal highlighting group anyway.
675func Test_1_highlight_Normalgroup_exists()
676  let hlNormal = HighlightArgs('Normal')
677  if !has('gui_running')
678    call assert_match('hi Normal\s*clear', hlNormal)
679  elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
680    " expect is DEFAULT_FONT of gui_gtk_x11.c
681    call assert_match('hi Normal\s*font=Monospace 10', hlNormal)
682  elseif has('gui_motif') || has('gui_athena')
683    " expect is DEFAULT_FONT of gui_x11.c
684    call assert_match('hi Normal\s*font=7x13', hlNormal)
685  elseif has('win32')
686    " expect any font
687    call assert_match('hi Normal\s*font=.*', hlNormal)
688  endif
689endfunc
690
691" Do this test last, sometimes restoring the columns doesn't work
692function Test_z_no_space_before_xxx()
693  let l:org_columns = &columns
694  set columns=17
695  let l:hi_StatusLineTermNC = join(split(execute('hi StatusLineTermNC')))
696  call assert_match('StatusLineTermNC xxx', l:hi_StatusLineTermNC)
697  let &columns = l:org_columns
698endfunction
699