robin/laufey

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

robinmerge: 1dc9728daa1d8a2702

master
33.6 KiB742 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 api, clear, eq = n.api, n.clear, t.eq
7local eval, exec, feed = n.eval, n.exec, n.feed
8local exec_lua = n.exec_lua
9
10describe('Signs', function()
11  local screen
12
13  before_each(function()
14    clear()
15    screen = Screen.new()
16    screen:add_extra_attr_ids {
17      [100] = { bold = true, foreground = Screen.colors.Magenta1 },
18      [101] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Yellow1 },
19      [102] = { foreground = Screen.colors.Brown, background = Screen.colors.Yellow },
20      [103] = { background = Screen.colors.Yellow, reverse = true },
21      [104] = { reverse = true, foreground = Screen.colors.Grey100, background = Screen.colors.Red },
22    }
23  end)
24
25  describe(':sign place', function()
26    it('allows signs with combining characters', function()
27      feed('ia<cr>b<cr><esc>')
28      exec([[
29        sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search
30        sign define piet2 text=𠜎̀́̂̃̄̅ texthl=Search
31        sign place 1 line=1 name=piet1 buffer=1
32        sign place 2 line=2 name=piet2 buffer=1
33      ]])
34      screen:expect([[
35        {101:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a                                                  |
36        {101:𠜎̀́̂̃̄̅}b                                                  |
37        {7:  }^                                                   |
38        {1:~                                                    }|*10
39                                                             |
40      ]])
41    end)
42
43    it('shadows previously placed signs', function()
44      feed('ia<cr>b<cr>c<cr><esc>')
45      exec([[
46        sign define piet text=>> texthl=Search
47        sign define pietx text=>! texthl=Search
48        sign place 1 line=1 name=piet buffer=1
49        sign place 2 line=3 name=piet buffer=1
50        sign place 3 line=1 name=pietx buffer=1
51      ]])
52      screen:expect([[
53        {101:>!}a                                                  |
54        {7:  }b                                                  |
55        {101:>>}c                                                  |
56        {7:  }^                                                   |
57        {1:~                                                    }|*9
58                                                             |
59      ]])
60    end)
61
62    it('allows signs with no text', function()
63      feed('ia<cr>b<cr><esc>')
64      exec('sign define piet1 text= texthl=Search')
65      exec('sign place 1 line=1 name=piet1 buffer=1')
66      screen:expect([[
67        a                                                    |
68        b                                                    |
69        ^                                                     |
70        {1:~                                                    }|*10
71                                                             |
72      ]])
73    end)
74
75    it('can be called right after :split', function()
76      feed('ia<cr>b<cr>c<cr><esc>gg')
77      -- This used to cause a crash due to :sign using a special redraw
78      -- (not updating nvim's specific highlight data structures)
79      -- without proper redraw first, as split just flags for redraw later.
80      exec([[
81        set cursorline
82        sign define piet text=>> texthl=Search
83        split
84        sign place 3 line=2 name=piet buffer=1
85      ]])
86      screen:expect([[
87        {7:  }{21:^a                                                  }|
88        {101:>>}b                                                  |
89        {7:  }c                                                  |
90        {7:  }                                                   |
91        {1:~                                                    }|*2
92        {3:[No Name] [+]                                        }|
93        {7:  }{21:a                                                  }|
94        {101:>>}b                                                  |
95        {7:  }c                                                  |
96        {7:  }                                                   |
97        {1:~                                                    }|
98        {2:[No Name] [+]                                        }|
99                                                             |
100      ]])
101    end)
102
103    it('can combine text, linehl and numhl', function()
104      feed('ia<cr>b<cr>c<cr><esc>')
105      exec([[
106        set number
107        sign define piet text=>> texthl=Search
108        sign define pietx linehl=ErrorMsg
109        sign define pietxx numhl=Folded
110        sign place 1 line=1 name=piet buffer=1
111        sign place 2 line=2 name=pietx buffer=1
112        sign place 3 line=3 name=pietxx buffer=1
113        sign place 4 line=4 name=piet buffer=1
114        sign place 5 line=4 name=pietx buffer=1
115        sign place 6 line=4 name=pietxx buffer=1
116      ]])
117      screen:expect([[
118        {101:>>}{8:  1 }a                                              |
119        {7:  }{8:  2 }{9:b                                              }|
120        {7:  }{13:  3 }c                                              |
121        {101:>>}{13:  4 }{9:^                                               }|
122        {1:~                                                    }|*9
123                                                             |
124      ]])
125      -- Check that 'statuscolumn' correctly applies numhl
126      exec('set statuscolumn=%s%=%l\\ ')
127      screen:expect_unchanged()
128    end)
129
130    it('highlights the cursorline sign with culhl', function()
131      feed('ia<cr>b<cr>c<esc>')
132      exec([[
133        sign define piet text=>> texthl=Search culhl=ErrorMsg
134        sign place 1 line=1 name=piet buffer=1
135        sign place 2 line=2 name=piet buffer=1
136        sign place 3 line=3 name=piet buffer=1
137        set cursorline
138      ]])
139      screen:expect([[
140        {101:>>}a                                                  |
141        {101:>>}b                                                  |
142        {9:>>}{21:^c                                                  }|
143        {1:~                                                    }|*10
144                                                             |
145      ]])
146      feed('k')
147      screen:expect([[
148        {101:>>}a                                                  |
149        {9:>>}{21:^b                                                  }|
150        {101:>>}c                                                  |
151        {1:~                                                    }|*10
152                                                             |
153      ]])
154      exec('set nocursorline')
155      screen:expect([[
156        {101:>>}a                                                  |
157        {101:>>}^b                                                  |
158        {101:>>}c                                                  |
159        {1:~                                                    }|*10
160                                                             |
161      ]])
162      exec('set cursorline cursorlineopt=line')
163      screen:expect([[
164        {101:>>}a                                                  |
165        {9:>>}{21:^b                                                  }|
166        {101:>>}c                                                  |
167        {1:~                                                    }|*10
168                                                             |
169      ]])
170      exec('set cursorlineopt=number')
171      exec('hi! link SignColumn IncSearch')
172      feed('Go<esc>2G')
173      screen:expect([[
174        {103:>>}a                                                  |
175        {104:>>}^b                                                  |
176        {103:>>}c                                                  |
177        {2:  }                                                   |
178        {1:~                                                    }|*9
179                                                             |
180      ]])
181
182      -- Check that 'statuscolumn' cursorline/signcolumn highlights are the same (#21726)
183      exec('set statuscolumn=%s')
184      screen:expect_unchanged()
185    end)
186
187    it('multiple signs #9295', function()
188      feed('ia<cr>b<cr>c<cr><esc>')
189      exec([[
190        set number
191        set signcolumn=yes:2
192        sign define pietSearch text=>> texthl=Search
193        sign define pietError text=XX texthl=Error
194        sign define pietWarn text=WW texthl=Warning
195        sign place 6 line=3 name=pietSearch buffer=1
196        sign place 7 line=3 name=pietWarn buffer=1
197        sign place 5 line=3 name=pietError buffer=1
198      ]])
199      -- Line 3 checks that with a limit over the maximum number
200      -- of signs, the ones with the highest Ids are being picked,
201      -- and presented by their sorted Id order.
202      screen:expect([[
203        {7:    }{8:  1 }a                                            |
204        {7:    }{8:  2 }b                                            |
205        {7:WW}{101:>>}{8:  3 }c                                            |
206        {7:    }{8:  4 }^                                             |
207        {1:~                                                    }|*9
208                                                             |
209      ]])
210      exec([[
211        sign place 1 line=1 name=pietSearch buffer=1
212        sign place 2 line=1 name=pietError buffer=1
213        " Line 2 helps checking that signs in the same line are ordered by Id.
214        sign place 4 line=2 name=pietSearch buffer=1
215        sign place 3 line=2 name=pietError buffer=1
216      ]])
217      screen:expect([[
218        {9:XX}{101:>>}{8:  1 }a                                            |
219        {101:>>}{9:XX}{8:  2 }b                                            |
220        {7:WW}{101:>>}{8:  3 }c                                            |
221        {7:    }{8:  4 }^                                             |
222        {1:~                                                    }|*9
223                                                             |
224      ]])
225      -- With the default setting, we get the sign with the top id.
226      exec('set signcolumn=yes:1')
227      screen:expect([[
228        {9:XX}{8:  1 }a                                              |
229        {101:>>}{8:  2 }b                                              |
230        {7:WW}{8:  3 }c                                              |
231        {7:  }{8:  4 }^                                               |
232        {1:~                                                    }|*9
233                                                             |
234      ]])
235      -- "auto:3" accommodates all the signs we defined so far.
236      exec('set signcolumn=auto:3')
237      local s3 = [[
238        {9:XX}{101:>>}{7:  }{8:  1 }a                                          |
239        {101:>>}{9:XX}{7:  }{8:  2 }b                                          |
240        {7:WW}{101:>>}{9:XX}{8:  3 }c                                          |
241        {7:      }{8:  4 }^                                           |
242        {1:~                                                    }|*9
243                                                             |
244      ]]
245      screen:expect(s3)
246      -- Check "yes:9".
247      exec('set signcolumn=yes:9')
248      screen:expect([[
249        {9:XX}{101:>>}{7:              }{8:  1 }a                              |
250        {101:>>}{9:XX}{7:              }{8:  2 }b                              |
251        {7:WW}{101:>>}{9:XX}{7:            }{8:  3 }c                              |
252        {7:                  }{8:  4 }^                               |
253        {1:~                                                    }|*9
254                                                             |
255      ]])
256      -- Check "auto:N" larger than the maximum number of signs defined in
257      -- a single line (same result as "auto:3").
258      exec('set signcolumn=auto:4')
259      screen:expect(s3)
260      -- line deletion deletes signs.
261      exec('3move1')
262      exec('2d')
263      screen:expect([[
264        {9:XX}{101:>>}{8:  1 }a                                            |
265        {101:>>}{9:XX}{8:  2 }^b                                            |
266        {7:    }{8:  3 }                                             |
267        {1:~                                                    }|*10
268                                                             |
269      ]])
270      -- character deletion does not delete signs.
271      feed('x')
272      screen:expect([[
273        {9:XX}{101:>>}{8:  1 }a                                            |
274        {101:>>}{9:XX}{8:  2 }^                                             |
275        {7:    }{8:  3 }                                             |
276        {1:~                                                    }|*10
277                                                             |
278      ]])
279    end)
280
281    it('auto-resize sign column with minimum size (#13783)', function()
282      feed('ia<cr>b<cr>c<cr><esc>')
283      exec('set number')
284      -- sign column should always accommodate at the minimum size
285      exec('set signcolumn=auto:1-3')
286      screen:expect([[
287        {7:  }{8:  1 }a                                              |
288        {7:  }{8:  2 }b                                              |
289        {7:  }{8:  3 }c                                              |
290        {7:  }{8:  4 }^                                               |
291        {1:~                                                    }|*9
292                                                             |
293      ]])
294      -- should support up to 8 signs at minimum
295      exec('set signcolumn=auto:8-9')
296      screen:expect([[
297        {7:                }{8:  1 }a                                |
298        {7:                }{8:  2 }b                                |
299        {7:                }{8:  3 }c                                |
300        {7:                }{8:  4 }^                                 |
301        {1:~                                                    }|*9
302                                                             |
303      ]])
304      -- should keep the same sign size when signs are not exceeding
305      -- the minimum
306      exec('set signcolumn=auto:2-5')
307      exec('sign define pietSearch text=>> texthl=Search')
308      exec('sign place 1 line=1 name=pietSearch buffer=1')
309      screen:expect([[
310        {101:>>}{7:  }{8:  1 }a                                            |
311        {7:    }{8:  2 }b                                            |
312        {7:    }{8:  3 }c                                            |
313        {7:    }{8:  4 }^                                             |
314        {1:~                                                    }|*9
315                                                             |
316      ]])
317      -- should resize itself when signs are exceeding minimum but
318      -- not over the maximum
319      exec([[
320        sign place 2 line=1 name=pietSearch buffer=1
321        sign place 3 line=1 name=pietSearch buffer=1
322        sign place 4 line=1 name=pietSearch buffer=1
323      ]])
324      screen:expect([[
325        {101:>>>>>>>>}{8:  1 }a                                        |
326        {7:        }{8:  2 }b                                        |
327        {7:        }{8:  3 }c                                        |
328        {7:        }{8:  4 }^                                         |
329        {1:~                                                    }|*9
330                                                             |
331      ]])
332      -- should not increase size because sign with existing id is moved
333      exec('sign place 4 line=1 name=pietSearch buffer=1')
334      screen:expect_unchanged()
335      exec('sign unplace 4')
336      screen:expect([[
337        {101:>>>>>>}{8:  1 }a                                          |
338        {7:      }{8:  2 }b                                          |
339        {7:      }{8:  3 }c                                          |
340        {7:      }{8:  4 }^                                           |
341        {1:~                                                    }|*9
342                                                             |
343      ]])
344      exec('sign place 4 line=1 name=pietSearch buffer=1')
345      -- should keep the column at maximum size when signs are
346      -- exceeding the maximum
347      exec([[
348        sign place 5 line=1 name=pietSearch buffer=1
349        sign place 6 line=1 name=pietSearch buffer=1
350        sign place 7 line=1 name=pietSearch buffer=1
351        sign place 8 line=1 name=pietSearch buffer=1
352      ]])
353      screen:expect([[
354        {101:>>>>>>>>>>}{8:  1 }a                                      |
355        {7:          }{8:  2 }b                                      |
356        {7:          }{8:  3 }c                                      |
357        {7:          }{8:  4 }^                                       |
358        {1:~                                                    }|*9
359                                                             |
360      ]])
361    end)
362
363    -- oldtest: Test_sign_number_without_signtext()
364    it('ignores signs with no icon and text when calculating the signcolumn width', function()
365      feed('ia<cr>b<cr>c<cr><esc>')
366      exec([[
367        set number
368        set signcolumn=auto:2
369        sign define pietSearch text=>> texthl=Search
370        sign define pietError text= texthl=Error
371        sign place 2 line=1 name=pietError buffer=1
372      ]])
373      -- no signcolumn with only empty sign
374      screen:expect([[
375        {8:  1 }a                                                |
376        {8:  2 }b                                                |
377        {8:  3 }c                                                |
378        {8:  4 }^                                                 |
379        {1:~                                                    }|*9
380                                                             |
381      ]])
382      -- single column with 1 sign with text and one sign without
383      exec('sign place 1 line=1 name=pietSearch buffer=1')
384      screen:expect([[
385        {101:>>}{8:  1 }a                                              |
386        {7:  }{8:  2 }b                                              |
387        {7:  }{8:  3 }c                                              |
388        {7:  }{8:  4 }^                                               |
389        {1:~                                                    }|*9
390                                                             |
391      ]])
392    end)
393
394    it('signcolumn=number', function()
395      feed('ia<cr>b<cr>c<cr><esc>')
396      exec([[
397        set number signcolumn=number
398        sign define pietSearch text=>> texthl=Search numhl=Error
399        sign define pietError text=    texthl=Search numhl=Error
400        sign place 1 line=1 name=pietSearch buffer=1
401        sign place 2 line=2 name=pietError  buffer=1
402      ]])
403      -- line number should be drawn if sign has no text
404      -- no signcolumn, line number for "a" is Search, for "b" is Error, for "c" is LineNr
405      screen:expect([[
406        {101: >> }a                                                |
407        {9:  2 }b                                                |
408        {8:  3 }c                                                |
409        {8:  4 }^                                                 |
410        {1:~                                                    }|*9
411                                                             |
412      ]])
413      -- number column on wrapped part of a line should be empty
414      feed('gg100aa<Esc>')
415      screen:expect([[
416        {101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
417        {9:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
418        {9:    }aa^a                                              |
419        {9:  2 }b                                                |
420        {8:  3 }c                                                |
421        {8:  4 }                                                 |
422        {1:~                                                    }|*7
423                                                             |
424      ]])
425      api.nvim_buf_set_extmark(0, api.nvim_create_namespace('test'), 0, 0, {
426        virt_lines = { { { 'VIRT LINES' } } },
427        virt_lines_above = true,
428      })
429      feed('<C-Y>')
430      -- number column on virtual lines should be empty
431      screen:expect([[
432        {9:    }VIRT LINES                                       |
433        {101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
434        {9:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
435        {9:    }aa^a                                              |
436        {9:  2 }b                                                |
437        {8:  3 }c                                                |
438        {8:  4 }                                                 |
439        {1:~                                                    }|*6
440                                                             |
441      ]])
442    end)
443
444    it('can have 32bit sign IDs', function()
445      exec('sign define piet text=>> texthl=Search')
446      exec('sign place 100000 line=1 name=piet buffer=1')
447      feed(':sign place<cr>')
448      screen:expect([[
449        {101:>>}                                                   |
450        {1:~                                                    }|*7
451        {3:                                                     }|
452        :sign place                                          |
453        {100:--- Signs ---}                                        |
454        {18:Signs for Untitled:}                                  |
455            line=1  id=100000  name=piet  priority=10        |
456        {6:Press ENTER or type command to continue}^              |
457      ]])
458
459      feed('<cr>')
460      screen:expect([[
461        {101:>>}^                                                   |
462        {1:~                                                    }|*12
463                                                             |
464      ]])
465    end)
466  end)
467
468  it('signcolumn width is updated when removing all signs after deleting lines', function()
469    api.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' })
470    exec('sign define piet text=>>')
471    exec('sign place 10001 line=1 name=piet')
472    exec('sign place 10002 line=5 name=piet')
473    exec('2delete')
474    exec('sign unplace 10001')
475    screen:expect([[
476      {7:  }a                                                  |
477      {7:  }^c                                                  |
478      {7:  }d                                                  |
479      {7:>>}e                                                  |
480      {1:~                                                    }|*9
481                                                           |
482    ]])
483    exec('sign unplace 10002')
484    screen:expect([[
485      a                                                    |
486      ^c                                                    |
487      d                                                    |
488      e                                                    |
489      {1:~                                                    }|*9
490                                                           |
491    ]])
492  end)
493
494  it('signcolumn width is updated when removing all signs after inserting lines', function()
495    api.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' })
496    exec('sign define piet text=>>')
497    exec('sign place 10001 line=1 name=piet')
498    exec('sign place 10002 line=5 name=piet')
499    exec('copy .')
500    exec('sign unplace 10001')
501    screen:expect([[
502      {7:  }a                                                  |
503      {7:  }^a                                                  |
504      {7:  }b                                                  |
505      {7:  }c                                                  |
506      {7:  }d                                                  |
507      {7:>>}e                                                  |
508      {1:~                                                    }|*7
509                                                           |
510    ]])
511    exec('sign unplace 10002')
512    screen:expect([[
513      a                                                    |
514      ^a                                                    |
515      b                                                    |
516      c                                                    |
517      d                                                    |
518      e                                                    |
519      {1:~                                                    }|*7
520                                                           |
521    ]])
522  end)
523
524  it('numhl highlight is applied when signcolumn=no', function()
525    screen:try_resize(screen._width, 4)
526    exec([[
527      set nu scl=no
528      call setline(1, ['line1', 'line2', 'line3'])
529      call nvim_buf_set_extmark(0, nvim_create_namespace('test'), 0, 0, {'number_hl_group':'Error'})
530      call sign_define('foo', { 'text':'F', 'numhl':'Error' })
531      call sign_place(0, '', 'foo', bufnr(''), { 'lnum':2 })
532    ]])
533    screen:expect([[
534      {9:  1 }^line1                                            |
535      {9:  2 }line2                                            |
536      {8:  3 }line3                                            |
537                                                           |
538    ]])
539  end)
540
541  it('no negative b_signcols.count with undo after initializing', function()
542    exec([[
543      set signcolumn=auto:2
544      call setline(1, 'a')
545      call nvim_buf_set_extmark(0, nvim_create_namespace(''), 0, 0, {'sign_text':'S1'})
546      delete | redraw | undo
547    ]])
548  end)
549
550  it('sign not shown on line it was previously on after undo', function()
551    exec([[
552      call setline(1, range(1, 4))
553      call nvim_buf_set_extmark(0, nvim_create_namespace(''), 1, 0, {'sign_text':'S1'})
554    ]])
555    exec('norm 2Gdd')
556    exec('silent undo')
557    -- Nvim: undo restores the cursor to where "2Gdd" started (|restore-undo-cursor|).
558    screen:expect([[
559      {7:  }^1                                                  |
560      {7:S1}2                                                  |
561      {7:  }3                                                  |
562      {7:  }4                                                  |
563      {1:~                                                    }|*9
564                                                           |
565    ]])
566  end)
567
568  it('sign_undefine() frees all signs', function()
569    exec([[
570      sign define 1 text=1
571      sign define 2 text=2
572      call sign_undefine()
573    ]])
574    eq({}, eval('sign_getdefined()'))
575  end)
576
577  it('no crash when unplacing signs beyond end of buffer', function()
578    exec([[
579      sign define S1 text=S1
580      sign define S2 text=S2
581      sign place 1 line=8 name=S1
582      sign place 2 line=9 name=S2
583    ]])
584    -- Now placed at end of buffer
585    local s1 = [[
586      {7:S2}^                                                   |
587      {1:~                                                    }|*12
588                                                           |
589    ]]
590    screen:expect(s1)
591    -- Signcolumn tracking used to not count signs placed beyond end of buffer here
592    exec('set signcolumn=auto:9')
593    screen:expect([[
594      {7:S2S1}^                                                 |
595      {1:~                                                    }|*12
596                                                           |
597    ]])
598    -- Unplacing the sign does not crash by decrementing tracked signs below zero
599    exec('sign unplace 1')
600    screen:expect(s1)
601  end)
602
603  it('signcolumn width is set immediately after splitting window #30547', function()
604    local infos = exec_lua([[
605      vim.o.number = true
606      vim.o.signcolumn = 'yes'
607      vim.cmd.wincmd('v')
608      return vim.fn.getwininfo()
609    ]])
610    eq(6, infos[1].textoff)
611    eq(6, infos[2].textoff)
612  end)
613
614  it('auto width updated in all windows after sign placed in on_win #31438', function()
615    exec_lua([[
616      vim.cmd.call('setline(1, range(1, 500))')
617      vim.cmd('wincmd s | wincmd v | wincmd j | wincmd v')
618
619      _G.log, _G.needs_clear = {}, false
620      local ns_id, mark_id = vim.api.nvim_create_namespace('test'), nil
621
622      -- Add decoration which possibly clears all extmarks and adds one on line 499
623      local on_win = function(_, winid, bufnr, toprow, botrow)
624        if _G.needs_clear then
625          vim.api.nvim_buf_clear_namespace(bufnr, ns_id, 0, -1)
626          _G.needs_clear = false
627        end
628
629        if toprow < 499 and 499 <= botrow then
630          mark_id = vim.api.nvim_buf_set_extmark(bufnr, ns_id, 499, 0, { id = mark_id, sign_text = '!', invalidate = true })
631        end
632      end
633      vim.api.nvim_set_decoration_provider(ns_id, { on_win = on_win })
634    ]])
635    screen:expect([[
636      1                         │1                         |
637      2                         │2                         |
638      3                         │3                         |
639      4                         │4                         |
640      5                         │5                         |
641      6                         │6                         |
642      {2:[No Name] [+]              [No Name] [+]             }|
643      ^1                         │1                         |
644      2                         │2                         |
645      3                         │3                         |
646      4                         │4                         |
647      5                         │5                         |
648      {3:[No Name] [+]              }{2:[No Name] [+]             }|
649                                                           |
650    ]])
651    feed('G')
652    screen:expect([[
653      {7:  }1                       │{7:  }1                       |
654      {7:  }2                       │{7:  }2                       |
655      {7:  }3                       │{7:  }3                       |
656      {7:  }4                       │{7:  }4                       |
657      {7:  }5                       │{7:  }5                       |
658      {7:  }6                       │{7:  }6                       |
659      {2:[No Name] [+]              [No Name] [+]             }|
660      {7:  }496                     │{7:  }1                       |
661      {7:  }497                     │{7:  }2                       |
662      {7:  }498                     │{7:  }3                       |
663      {7:  }499                     │{7:  }4                       |
664      {7:! }^500                     │{7:  }5                       |
665      {3:[No Name] [+]              }{2:[No Name] [+]             }|
666                                                           |
667    ]])
668    feed(':lua log, needs_clear = {}, true<CR>')
669    screen:expect([[
670      {7:  }1                       │{7:  }1                       |
671      {7:  }2                       │{7:  }2                       |
672      {7:  }3                       │{7:  }3                       |
673      {7:  }4                       │{7:  }4                       |
674      {7:  }5                       │{7:  }5                       |
675      {7:  }6                       │{7:  }6                       |
676      {2:[No Name] [+]              [No Name] [+]             }|
677      {7:  }496                     │{7:  }1                       |
678      {7:  }497                     │{7:  }2                       |
679      {7:  }498                     │{7:  }3                       |
680      {7:  }499                     │{7:  }4                       |
681      {7:! }^500                     │{7:  }5                       |
682      {3:[No Name] [+]              }{2:[No Name] [+]             }|
683      :lua log, needs_clear = {}, true                     |
684    ]])
685  end)
686
687  it('signcolumn tracking does not consider signs beyond eob', function()
688    api.nvim_set_option_value('signcolumn', 'auto:2', {})
689    api.nvim_buf_set_extmark(0, api.nvim_create_namespace(''), 1, 0, { sign_text = 's' })
690    api.nvim_buf_set_lines(0, 0, -1, false, {})
691    n.assert_alive()
692  end)
693
694  it("with line that doesn't fit in window", function()
695    screen:try_resize(40, 9)
696    api.nvim_set_option_value('foldcolumn', '1', {})
697    api.nvim_set_option_value('number', true, {})
698    api.nvim_set_option_value('signcolumn', 'yes:2', {})
699    api.nvim_set_hl(0, 'FoldColumn', { link = 'StatusLine' })
700    api.nvim_buf_set_lines(
701      0,
702      0,
703      -1,
704      false,
705      { ('a'):rep(90), ('b'):rep(90), ('c'):rep(90), ('d'):rep(90), ('e'):rep(90) }
706    )
707    screen:expect([[
708      {3: }{7:    }{8:  1 }^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
709      {3: }{7:    }{8:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
710      {3: }{7:    }{8:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaa   |
711      {3: }{7:    }{8:  2 }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
712      {3: }{7:    }{8:    }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
713      {3: }{7:    }{8:    }bbbbbbbbbbbbbbbbbbbbbbbbbbbb   |
714      {3: }{7:    }{8:  3 }ccccccccccccccccccccccccccccccc|
715      {3: }{7:    }{8:    }cccccccccccccccccccccccccccc{1:@@@}|
716                                              |
717    ]])
718    api.nvim_set_option_value('display', 'truncate', {})
719    screen:expect([[
720      {3: }{7:    }{8:  1 }^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
721      {3: }{7:    }{8:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
722      {3: }{7:    }{8:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaa   |
723      {3: }{7:    }{8:  2 }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
724      {3: }{7:    }{8:    }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
725      {3: }{7:    }{8:    }bbbbbbbbbbbbbbbbbbbbbbbbbbbb   |
726      {3: }{7:    }{8:  3 }ccccccccccccccccccccccccccccccc|
727      {1:@@@                                     }|
728                                              |
729    ]])
730    api.nvim_set_option_value('display', '', {})
731    screen:expect([[
732      {3: }{7:    }{8:  1 }^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
733      {3: }{7:    }{8:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
734      {3: }{7:    }{8:    }aaaaaaaaaaaaaaaaaaaaaaaaaaaa   |
735      {3: }{7:    }{8:  2 }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
736      {3: }{7:    }{8:    }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
737      {3: }{7:    }{8:    }bbbbbbbbbbbbbbbbbbbbbbbbbbbb   |
738      {3: }{7:    }{8:    }{1:@                              }|*2
739                                              |
740    ]])
741  end)
742end)