robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
3.8 KiB120 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3local Screen = require('test.functional.ui.screen')
4
5local describe, it, before_each = t.describe, t.it, t.before_each
6local clear, feed = n.clear, n.feed
7local expect = n.expect
8local eq = t.eq
9local pcall_err = t.pcall_err
10local poke_eventloop = n.poke_eventloop
11local feed_command = n.feed_command
12local exec = n.exec
13local command = n.command
14
15before_each(clear)
16
17describe(':highlight', function()
18  it('is working', function()
19    local screen = Screen.new(35, 10)
20    -- Basic test if ":highlight" doesn't crash
21    feed_command('set more')
22    feed(':highlight<CR>')
23    -- FIXME(tarruda): We need to be sure the prompt is displayed before
24    -- continuing, or risk a race condition where some of the following input
25    -- is discarded resulting in test failure
26    screen:expect([[
27      :highlight                         |
28      SpecialKey     {18:xxx} {18:ctermfg=}4       |
29                         {18:guifg=}Blue      |
30      EndOfBuffer    {1:xxx} {18:links to} NonText|
31                                         |
32      TermCursor     {2:xxx} {18:cterm=}reverse   |
33                         {18:gui=}reverse     |
34      NonText        {1:xxx} {18:ctermfg=}12      |
35                         {18:gui=}bold        |
36      {6:-- More --}^                         |
37    ]])
38    feed('q')
39    poke_eventloop() -- wait until we're back to normal
40    feed_command('hi Search')
41    feed_command('hi Normal')
42
43    -- Test setting colors.
44    -- Test clearing one color and all doesn't generate error or warning
45    feed_command(
46      'hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan'
47    )
48    feed_command('hi Group2 cterm=NONE')
49    feed_command('hi Group3 cterm=bold')
50    feed_command('redir! @a')
51    feed_command('hi NewGroup')
52    feed_command('hi Group2')
53    feed_command('hi Group3')
54    feed_command('hi clear NewGroup')
55    feed_command('hi NewGroup')
56    feed_command('hi Group2')
57    feed_command('hi Group2 NONE')
58    feed_command('hi Group2')
59    feed_command('hi clear')
60    feed_command('hi Group3')
61    feed('<cr>')
62    eq(
63      "Vim(highlight):E475: Invalid argument: cterm='asdf",
64      pcall_err(command, [[hi Crash cterm='asdf]])
65    )
66    feed_command('redir END')
67
68    -- Filter ctermfg and ctermbg, the numbers depend on the terminal
69    feed_command('0put a')
70    feed_command([[%s/ctermfg=\d*/ctermfg=2/]])
71    feed_command([[%s/ctermbg=\d*/ctermbg=3/]])
72
73    -- Fix the fileformat
74    feed_command('set ff&')
75    feed_command('$d')
76
77    -- Assert buffer contents.
78    expect([[
79
80
81      NewGroup       xxx cterm=italic
82                         ctermfg=2
83                         ctermbg=3
84                         guifg=#00ff00
85                         guibg=Cyan
86
87      Group2         xxx cleared
88
89      Group3         xxx cterm=bold
90
91
92      NewGroup       xxx cleared
93
94      Group2         xxx cleared
95
96
97      Group2         xxx cleared
98
99
100      Group3         xxx cleared]])
101  end)
102end)
103
104describe('Visual selection highlight', function()
105  -- oldtest: Test_visual_sbr()
106  it("when 'showbreak' is set", function()
107    local screen = Screen.new(60, 6)
108    exec([[
109      set showbreak=>
110      call setline(1, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.')
111      exe "normal! z1\<CR>"
112    ]])
113    feed('v$')
114    screen:expect([[
115      {1:>}{17:n, no sea takimata sanctus est Lorem ipsum dolor sit amet.}^ |
116                                                                  |*4
117      {5:-- VISUAL --}                                                |
118    ]])
119  end)
120end)