robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
6.7 KiB209 linesraw
1local n = require('test.functional.testnvim')()
2local t = require('test.testutil')
3local Screen = require('test.functional.ui.screen')
4
5local describe, it, before_each = t.describe, t.it, t.before_each
6local clear, feed, api = n.clear, n.feed, n.api
7local insert, command = n.insert, n.command
8
9describe('quickfix', function()
10  local screen
11
12  before_each(function()
13    clear()
14    screen = Screen.new(25, 10)
15    screen:add_extra_attr_ids({
16      [100] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.WebGreen },
17      [101] = { foreground = Screen.colors.Brown, background = Screen.colors.WebGreen },
18      [102] = { background = Screen.colors.WebGreen },
19      [103] = { background = Screen.colors.Red, foreground = Screen.colors.SlateBlue },
20      [104] = { background = Screen.colors.Red, foreground = Screen.colors.Brown },
21      [105] = { background = Screen.colors.Fuchsia },
22      [106] = { foreground = Screen.colors.Red, background = Screen.colors.Fuchsia },
23      [107] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Fuchsia },
24      [108] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia },
25    })
26
27    api.nvim_set_option_value('errorformat', '%m %l', {})
28    command('syntax on')
29    command('highlight Search guibg=Green')
30
31    insert([[
32    Line 1
33    Line 2
34    Line 3
35    Line 4
36    Line 5
37    ]])
38
39    command('cad')
40    feed('gg')
41
42    screen:expect([[
43      ^Line 1                   |
44      Line 2                   |
45      Line 3                   |
46      Line 4                   |
47      Line 5                   |
48                               |
49      {1:~                        }|*3
50                               |
51    ]])
52  end)
53
54  it('Search selection highlight', function()
55    command('copen')
56
57    screen:expect([[
58      Line 1                   |
59      {2:[No Name] [+]            }|
60      {100:^|}{101:1}{100:|}{102: Line                 }|
61      {16:|}{8:2}{16:|} Line                 |
62      {16:|}{8:3}{16:|} Line                 |
63      {16:|}{8:4}{16:|} Line                 |
64      {16:|}{8:5}{16:|} Line                 |
65      {16:||}                       |
66      {3:[Quickfix List] [-]      }|
67                               |
68    ]])
69
70    command('cnext')
71
72    screen:expect([[
73      Line 1                   |
74      {2:[No Name] [+]            }|
75      {16:|}{8:1}{16:|} Line                 |
76      {100:^|}{101:2}{100:|}{102: Line                 }|
77      {16:|}{8:3}{16:|} Line                 |
78      {16:|}{8:4}{16:|} Line                 |
79      {16:|}{8:5}{16:|} Line                 |
80      {16:||}                       |
81      {3:[Quickfix List] [-]      }|
82                               |
83    ]])
84  end)
85
86  it('QuickFixLine selection highlight', function()
87    command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
88
89    command('copen')
90
91    screen:expect([[
92      Line 1                   |
93      {2:[No Name] [+]            }|
94      {103:^|}{104:1}{103:|}{30: Line                 }|
95      {16:|}{8:2}{16:|} Line                 |
96      {16:|}{8:3}{16:|} Line                 |
97      {16:|}{8:4}{16:|} Line                 |
98      {16:|}{8:5}{16:|} Line                 |
99      {16:||}                       |
100      {3:[Quickfix List] [-]      }|
101                               |
102    ]])
103
104    command('cnext')
105
106    screen:expect([[
107      Line 1                   |
108      {2:[No Name] [+]            }|
109      {16:|}{8:1}{16:|} Line                 |
110      {103:^|}{104:2}{103:|}{30: Line                 }|
111      {16:|}{8:3}{16:|} Line                 |
112      {16:|}{8:4}{16:|} Line                 |
113      {16:|}{8:5}{16:|} Line                 |
114      {16:||}                       |
115      {3:[Quickfix List] [-]      }|
116                               |
117    ]])
118  end)
119
120  it('selection highlight combines with CursorLine', function()
121    command('set cursorline')
122    command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE')
123    command('highlight CursorLine guibg=Fuchsia')
124
125    command('copen')
126
127    screen:expect([[
128      {105:Line 1                   }|
129      {2:[No Name] [+]            }|
130      {106:^|1| Line                 }|
131      {16:|}{8:2}{16:|} Line                 |
132      {16:|}{8:3}{16:|} Line                 |
133      {16:|}{8:4}{16:|} Line                 |
134      {16:|}{8:5}{16:|} Line                 |
135      {16:||}                       |
136      {3:[Quickfix List] [-]      }|
137                               |
138    ]])
139
140    feed('j')
141
142    screen:expect([[
143      {105:Line 1                   }|
144      {2:[No Name] [+]            }|
145      {19:|1| Line                 }|
146      {107:^|}{108:2}{107:|}{105: Line                 }|
147      {16:|}{8:3}{16:|} Line                 |
148      {16:|}{8:4}{16:|} Line                 |
149      {16:|}{8:5}{16:|} Line                 |
150      {16:||}                       |
151      {3:[Quickfix List] [-]      }|
152                               |
153    ]])
154  end)
155
156  it('QuickFixLine selection highlight background takes precedence over CursorLine', function()
157    command('set cursorline')
158    command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
159    command('highlight CursorLine guibg=Fuchsia')
160
161    command('copen')
162
163    screen:expect([[
164      {105:Line 1                   }|
165      {2:[No Name] [+]            }|
166      {103:^|}{104:1}{103:|}{30: Line                 }|
167      {16:|}{8:2}{16:|} Line                 |
168      {16:|}{8:3}{16:|} Line                 |
169      {16:|}{8:4}{16:|} Line                 |
170      {16:|}{8:5}{16:|} Line                 |
171      {16:||}                       |
172      {3:[Quickfix List] [-]      }|
173                               |
174    ]])
175
176    feed('j')
177
178    screen:expect([[
179      {105:Line 1                   }|
180      {2:[No Name] [+]            }|
181      {103:|}{104:1}{103:|}{30: Line                 }|
182      {107:^|}{108:2}{107:|}{105: Line                 }|
183      {16:|}{8:3}{16:|} Line                 |
184      {16:|}{8:4}{16:|} Line                 |
185      {16:|}{8:5}{16:|} Line                 |
186      {16:||}                       |
187      {3:[Quickfix List] [-]      }|
188                               |
189    ]])
190  end)
191
192  it('does not inherit from non-current floating window', function()
193    api.nvim_open_win(0, true, { width = 6, height = 2, relative = 'win', bufpos = { 3, 0 } })
194    api.nvim_set_option_value('rightleft', true, { win = 0 })
195    command('wincmd w | copen')
196    screen:expect([[
197      Line 1                   |
198      {2:[No Name] [+]            }|
199      {100:^|}{101:1}{100:|}{102: Line                 }|
200      {16:|}{8:2}{16:|} Line           {4:1 eniL}|
201      {16:|}{8:3}{16:|} Line           {4:2 eniL}|
202      {16:|}{8:4}{16:|} Line                 |
203      {16:|}{8:5}{16:|} Line                 |
204      {16:||}                       |
205      {3:[Quickfix List] [-]      }|
206                               |
207    ]])
208  end)
209end)