robin/laufey

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

robinmerge: 1dc9728daa1d8a2702

master
116.6 KiB3099 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, eq = n.clear, n.feed, t.eq
7local command = n.command
8local feed_command = n.feed_command
9local insert = n.insert
10local fn = n.fn
11local api = n.api
12local exec = n.exec
13local assert_alive = n.assert_alive
14
15local content1 = [[
16        This is a
17        valid English
18        sentence composed by
19        an exhausted developer
20        in his cave.
21        ]]
22
23describe('folded lines', function()
24  before_each(function()
25    clear()
26    command('hi VertSplit gui=reverse')
27  end)
28
29  local function with_ext_multigrid(multigrid)
30    local screen
31    before_each(function()
32      screen = Screen.new(45, 8, { rgb = true, ext_multigrid = multigrid })
33      screen:add_extra_attr_ids({
34        [100] = { foreground = Screen.colors.Red },
35        [101] = { foreground = Screen.colors.Red, background = Screen.colors.LightGrey },
36        [102] = { underline = true },
37        [103] = { foreground = Screen.colors.Blue4, background = Screen.colors.Red },
38        [104] = {
39          bold = true,
40          background = Screen.colors.LightGray,
41          foreground = Screen.colors.Blue1,
42        },
43        [105] = { background = Screen.colors.Yellow1, foreground = Screen.colors.Blue4 },
44        [106] = { bold = true, background = Screen.colors.Red, foreground = Screen.colors.Blue1 },
45        [107] = { background = Screen.colors.LightGrey, foreground = Screen.colors.WebGreen },
46        [108] = { foreground = Screen.colors.Green, background = Screen.colors.Red },
47        [109] = { foreground = Screen.colors.Blue, bold = true, background = Screen.colors.Yellow1 },
48      })
49    end)
50
51    it('with more than one signcolumn', function()
52      command('set signcolumn=yes:9')
53      feed('i<cr><esc>')
54      feed('vkzf')
55      if multigrid then
56        screen:expect([[
57        ## grid 1
58          [2:---------------------------------------------]|*7
59          [3:---------------------------------------------]|
60        ## grid 2
61          {7:                  }{13:^+--  2 lines: ·············}|
62          {1:~                                            }|*6
63        ## grid 3
64                                                       |
65        ]])
66      else
67        screen:expect([[
68          {7:                  }{13:^+--  2 lines: ·············}|
69          {1:~                                            }|*6
70                                                       |
71        ]])
72      end
73    end)
74
75    local function test_folded_cursorline(foldtext)
76      if not foldtext then
77        command('set foldtext=')
78      end
79      command('set number cursorline foldcolumn=2')
80      command('hi link CursorLineFold Search')
81      insert(content1)
82      feed('ggzf3jj')
83
84      if multigrid then
85        if foldtext then
86          screen:expect([[
87          ## grid 1
88            [2:---------------------------------------------]|*7
89            [3:---------------------------------------------]|
90          ## grid 2
91            {7:+ }{8:  1 }{13:+--  4 lines: This is a················}|
92            {10:  }{15:  5 }{100:^in his cave.                           }|
93            {7:  }{8:  6 }                                       |
94            {1:~                                            }|*4
95          ## grid 3
96                                                         |
97          ]])
98        else
99          screen:expect([[
100          ## grid 1
101            [2:---------------------------------------------]|*7
102            [3:---------------------------------------------]|
103          ## grid 2
104            {7:+ }{8:  1 }{13:This is a······························}|
105            {10:  }{15:  5 }{100:^in his cave.                           }|
106            {7:  }{8:  6 }                                       |
107            {1:~                                            }|*4
108          ## grid 3
109                                                         |
110          ]])
111        end
112      else
113        if foldtext then
114          screen:expect([[
115            {7:+ }{8:  1 }{13:+--  4 lines: This is a················}|
116            {10:  }{15:  5 }{100:^in his cave.                           }|
117            {7:  }{8:  6 }                                       |
118            {1:~                                            }|*4
119                                                         |
120          ]])
121        else
122          screen:expect([[
123            {7:+ }{8:  1 }{13:This is a······························}|
124            {10:  }{15:  5 }{100:^in his cave.                           }|
125            {7:  }{8:  6 }                                       |
126            {1:~                                            }|*4
127                                                         |
128          ]])
129        end
130      end
131
132      feed('k')
133
134      if multigrid then
135        if foldtext then
136          screen:expect([[
137          ## grid 1
138            [2:---------------------------------------------]|*7
139            [3:---------------------------------------------]|
140          ## grid 2
141            {10:+ }{15:  1 }{101:^+--  4 lines: This is a················}|
142            {7:  }{8:  5 }in his cave.                           |
143            {7:  }{8:  6 }                                       |
144            {1:~                                            }|*4
145          ## grid 3
146                                                         |
147          ]])
148        else
149          screen:expect([[
150          ## grid 1
151            [2:---------------------------------------------]|*7
152            [3:---------------------------------------------]|
153          ## grid 2
154            {10:+ }{15:  1 }{101:^This is a······························}|
155            {7:  }{8:  5 }in his cave.                           |
156            {7:  }{8:  6 }                                       |
157            {1:~                                            }|*4
158          ## grid 3
159                                                         |
160          ]])
161        end
162      else
163        if foldtext then
164          screen:expect([[
165            {10:+ }{15:  1 }{101:^+--  4 lines: This is a················}|
166            {7:  }{8:  5 }in his cave.                           |
167            {7:  }{8:  6 }                                       |
168            {1:~                                            }|*4
169                                                         |
170          ]])
171        else
172          screen:expect([[
173            {10:+ }{15:  1 }{101:^This is a······························}|
174            {7:  }{8:  5 }in his cave.                           |
175            {7:  }{8:  6 }                                       |
176            {1:~                                            }|*4
177                                                         |
178          ]])
179        end
180      end
181
182      -- CursorLine is applied correctly with screenrow motions #22232
183      feed('jgk')
184      screen:expect_unchanged()
185      -- CursorLine is applied correctly when closing a fold when cursor is not at fold start
186      feed('zo4Gzc')
187      screen:expect_unchanged()
188      command('set cursorlineopt=line')
189
190      if multigrid then
191        if foldtext then
192          screen:expect([[
193          ## grid 1
194            [2:---------------------------------------------]|*7
195            [3:---------------------------------------------]|
196          ## grid 2
197            {10:+ }{8:  1 }{101:^+--  4 lines: This is a················}|
198            {7:  }{8:  5 }in his cave.                           |
199            {7:  }{8:  6 }                                       |
200            {1:~                                            }|*4
201          ## grid 3
202                                                         |
203          ]])
204        else
205          screen:expect([[
206          ## grid 1
207            [2:---------------------------------------------]|*7
208            [3:---------------------------------------------]|
209          ## grid 2
210            {10:+ }{8:  1 }{101:^This is a······························}|
211            {7:  }{8:  5 }in his cave.                           |
212            {7:  }{8:  6 }                                       |
213            {1:~                                            }|*4
214          ## grid 3
215                                                         |
216          ]])
217        end
218      else
219        if foldtext then
220          screen:expect([[
221            {10:+ }{8:  1 }{101:^+--  4 lines: This is a················}|
222            {7:  }{8:  5 }in his cave.                           |
223            {7:  }{8:  6 }                                       |
224            {1:~                                            }|*4
225                                                         |
226          ]])
227        else
228          screen:expect([[
229            {10:+ }{8:  1 }{101:^This is a······························}|
230            {7:  }{8:  5 }in his cave.                           |
231            {7:  }{8:  6 }                                       |
232            {1:~                                            }|*4
233                                                         |
234          ]])
235        end
236      end
237
238      command('set relativenumber cursorlineopt=number')
239
240      if multigrid then
241        if foldtext then
242          screen:expect([[
243          ## grid 1
244            [2:---------------------------------------------]|*7
245            [3:---------------------------------------------]|
246          ## grid 2
247            {10:+ }{15:1   }{13:^+--  4 lines: This is a················}|
248            {7:  }{8:  1 }in his cave.                           |
249            {7:  }{8:  2 }                                       |
250            {1:~                                            }|*4
251          ## grid 3
252                                                         |
253          ]])
254        else
255          screen:expect([[
256          ## grid 1
257            [2:---------------------------------------------]|*7
258            [3:---------------------------------------------]|
259          ## grid 2
260            {10:+ }{15:1   }{13:^This is a······························}|
261            {7:  }{8:  1 }in his cave.                           |
262            {7:  }{8:  2 }                                       |
263            {1:~                                            }|*4
264          ## grid 3
265                                                         |
266          ]])
267        end
268      else
269        if foldtext then
270          screen:expect([[
271            {10:+ }{15:1   }{13:^+--  4 lines: This is a················}|
272            {7:  }{8:  1 }in his cave.                           |
273            {7:  }{8:  2 }                                       |
274            {1:~                                            }|*4
275                                                         |
276          ]])
277        else
278          screen:expect([[
279            {10:+ }{15:1   }{13:^This is a······························}|
280            {7:  }{8:  1 }in his cave.                           |
281            {7:  }{8:  2 }                                       |
282            {1:~                                            }|*4
283                                                         |
284          ]])
285        end
286      end
287    end
288
289    describe("when 'cursorline' is set", function()
290      local function cursorline_tests(foldtext)
291        local sfx = not foldtext and ' (transparent foldtext)' or ''
292        it('with high-priority CursorLine' .. sfx, function()
293          command('hi! CursorLine guibg=NONE guifg=Red gui=NONE')
294          test_folded_cursorline(foldtext)
295        end)
296
297        it('with low-priority CursorLine' .. sfx, function()
298          command('hi! CursorLine guibg=NONE guifg=NONE gui=underline')
299          screen:add_extra_attr_ids({
300            [100] = { underline = true },
301            [101] = {
302              background = Screen.colors.LightGray,
303              underline = true,
304              foreground = Screen.colors.Blue4,
305            },
306          })
307          test_folded_cursorline(foldtext)
308        end)
309      end
310
311      cursorline_tests(true)
312      cursorline_tests(false)
313    end)
314
315    it('with spell', function()
316      command('set spell')
317      insert(content1)
318
319      feed('gg')
320      feed('zf3j')
321      if not multigrid then
322        screen:expect([[
323          {13:^+--  4 lines: This is a······················}|
324          in his cave.                                 |
325                                                       |
326          {1:~                                            }|*4
327                                                       |
328        ]])
329      end
330    end)
331
332    it('with matches', function()
333      insert(content1)
334      command('highlight MyWord gui=bold guibg=red   guifg=white')
335      command("call matchadd('MyWord', '\\V' . 'test', -1)")
336      feed('gg')
337      feed('zf3j')
338      if not multigrid then
339        screen:expect([[
340          {13:^+--  4 lines: This is a······················}|
341          in his cave.                                 |
342                                                       |
343          {1:~                                            }|*4
344                                                       |
345        ]])
346      end
347    end)
348
349    it('with multibyte fillchars', function()
350      insert([[
351        aa
352        bb
353        cc
354        dd
355        ee
356        ff]])
357      command('set fillchars+=foldopen:▾,foldsep:│,foldclose:▸')
358      feed_command('1')
359      command('set foldcolumn=2')
360      feed('zf4j')
361      feed('zf2j')
362      feed('zO')
363      if multigrid then
364        screen:expect([[
365        ## grid 1
366          [2:---------------------------------------------]|*7
367          [3:---------------------------------------------]|
368        ## grid 2
369          {7:▾▾}^aa                                         |
370          {7:││}bb                                         |
371          {7:││}cc                                         |
372          {7:││}dd                                         |
373          {7:││}ee                                         |
374          {7:│ }ff                                         |
375          {1:~                                            }|
376        ## grid 3
377          :1                                           |
378        ]])
379      else
380        screen:expect([[
381          {7:▾▾}^aa                                         |
382          {7:││}bb                                         |
383          {7:││}cc                                         |
384          {7:││}dd                                         |
385          {7:││}ee                                         |
386          {7:│ }ff                                         |
387          {1:~                                            }|
388          :1                                           |
389        ]])
390      end
391
392      feed_command('set rightleft')
393      if multigrid then
394        screen:expect([[
395        ## grid 1
396          [2:---------------------------------------------]|*7
397          [3:---------------------------------------------]|
398        ## grid 2
399                                                   a^a{7:▾▾}|
400                                                   bb{7:││}|
401                                                   cc{7:││}|
402                                                   dd{7:││}|
403                                                   ee{7:││}|
404                                                   ff{7: │}|
405          {1:                                            ~}|
406        ## grid 3
407          :set rightleft                               |
408        ]])
409      else
410        screen:expect([[
411                                                   a^a{7:▾▾}|
412                                                   bb{7:││}|
413                                                   cc{7:││}|
414                                                   dd{7:││}|
415                                                   ee{7:││}|
416                                                   ff{7: │}|
417          {1:                                            ~}|
418          :set rightleft                               |
419        ]])
420      end
421
422      feed_command('set norightleft')
423      if multigrid then
424        api.nvim_input_mouse('left', 'press', '', 2, 0, 1)
425        screen:expect([[
426        ## grid 1
427          [2:---------------------------------------------]|*7
428          [3:---------------------------------------------]|
429        ## grid 2
430          {7:▾▸}{13:^+---  5 lines: aa··························}|
431          {7:│ }ff                                         |
432          {1:~                                            }|*5
433        ## grid 3
434          :set norightleft                             |
435        ]])
436      else
437        api.nvim_input_mouse('left', 'press', '', 0, 0, 1)
438        screen:expect([[
439          {7:▾▸}{13:^+---  5 lines: aa··························}|
440          {7:│ }ff                                         |
441          {1:~                                            }|*5
442          :set norightleft                             |
443        ]])
444      end
445
446      if multigrid then
447        api.nvim_input_mouse('left', 'press', '', 2, 0, 0)
448        screen:expect([[
449        ## grid 1
450          [2:---------------------------------------------]|*7
451          [3:---------------------------------------------]|
452        ## grid 2
453          {7:▸ }{13:^+--  6 lines: aa···························}|
454          {1:~                                            }|*6
455        ## grid 3
456          :set norightleft                             |
457        ]])
458      else
459        api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
460        screen:expect([[
461          {7:▸ }{13:^+--  6 lines: aa···························}|
462          {1:~                                            }|*6
463          :set norightleft                             |
464        ]])
465      end
466
467      -- Add a winbar to avoid double-clicks
468      command('setlocal winbar=!!!!!!')
469      if multigrid then
470        api.nvim_input_mouse('left', 'press', '', 2, 1, 0)
471        screen:expect([[
472        ## grid 1
473          [2:---------------------------------------------]|*7
474          [3:---------------------------------------------]|
475        ## grid 2
476          {5:!!!!!!                                       }|
477          {7:▾▸}{13:^+---  5 lines: aa··························}|
478          {7:│ }ff                                         |
479          {1:~                                            }|*4
480        ## grid 3
481          :set norightleft                             |
482        ]])
483      else
484        api.nvim_input_mouse('left', 'press', '', 0, 1, 0)
485        screen:expect([[
486          {5:!!!!!!                                       }|
487          {7:▾▸}{13:^+---  5 lines: aa··························}|
488          {7:│ }ff                                         |
489          {1:~                                            }|*4
490          :set norightleft                             |
491        ]])
492      end
493
494      if multigrid then
495        api.nvim_input_mouse('left', 'press', '', 2, 1, 1)
496        screen:expect([[
497        ## grid 1
498          [2:---------------------------------------------]|*7
499          [3:---------------------------------------------]|
500        ## grid 2
501          {5:!!!!!!                                       }|
502          {7:▾▾}^aa                                         |
503          {7:││}bb                                         |
504          {7:││}cc                                         |
505          {7:││}dd                                         |
506          {7:││}ee                                         |
507          {7:│ }ff                                         |
508        ## grid 3
509          :set norightleft                             |
510        ]])
511      else
512        api.nvim_input_mouse('left', 'press', '', 0, 1, 1)
513        screen:expect([[
514          {5:!!!!!!                                       }|
515          {7:▾▾}^aa                                         |
516          {7:││}bb                                         |
517          {7:││}cc                                         |
518          {7:││}dd                                         |
519          {7:││}ee                                         |
520          {7:│ }ff                                         |
521          :set norightleft                             |
522        ]])
523      end
524    end)
525
526    it('with split', function()
527      insert([[
528        aa
529        bb
530        cc
531        dd
532        ee
533        ff]])
534      feed_command('2')
535      command('set foldcolumn=1')
536      feed('zf3j')
537      feed_command('1')
538      feed('zf2j')
539      feed('zO')
540      feed_command('rightbelow new')
541      insert([[
542        aa
543        bb
544        cc
545        dd
546        ee
547        ff]])
548      feed_command('2')
549      command('set foldcolumn=1')
550      feed('zf3j')
551      feed_command('1')
552      feed('zf2j')
553      if multigrid then
554        api.nvim_input_mouse('left', 'press', '', 4, 0, 0)
555        screen:expect([[
556        ## grid 1
557          [2:---------------------------------------------]|*2
558          {2:[No Name] [+]                                }|
559          [4:---------------------------------------------]|*3
560          {3:[No Name] [+]                                }|
561          [3:---------------------------------------------]|
562        ## grid 2
563          {7:-}aa                                          |
564          {7:-}bb                                          |
565        ## grid 3
566          :1                                           |
567        ## grid 4
568          {7:-}^aa                                          |
569          {7:+}{13:+---  4 lines: bb···························}|
570          {7:│}ff                                          |
571        ]])
572      else
573        api.nvim_input_mouse('left', 'press', '', 0, 3, 0)
574        screen:expect([[
575          {7:-}aa                                          |
576          {7:-}bb                                          |
577          {2:[No Name] [+]                                }|
578          {7:-}^aa                                          |
579          {7:+}{13:+---  4 lines: bb···························}|
580          {7:│}ff                                          |
581          {3:[No Name] [+]                                }|
582          :1                                           |
583        ]])
584      end
585
586      if multigrid then
587        api.nvim_input_mouse('left', 'press', '', 4, 1, 0)
588        screen:expect([[
589        ## grid 1
590          [2:---------------------------------------------]|*2
591          {2:[No Name] [+]                                }|
592          [4:---------------------------------------------]|*3
593          {3:[No Name] [+]                                }|
594          [3:---------------------------------------------]|
595        ## grid 2
596          {7:-}aa                                          |
597          {7:-}bb                                          |
598        ## grid 3
599          :1                                           |
600        ## grid 4
601          {7:-}^aa                                          |
602          {7:-}bb                                          |
603          {7:2}cc                                          |
604        ]])
605      else
606        api.nvim_input_mouse('left', 'press', '', 0, 4, 0)
607        screen:expect([[
608          {7:-}aa                                          |
609          {7:-}bb                                          |
610          {2:[No Name] [+]                                }|
611          {7:-}^aa                                          |
612          {7:-}bb                                          |
613          {7:2}cc                                          |
614          {3:[No Name] [+]                                }|
615          :1                                           |
616        ]])
617      end
618
619      if multigrid then
620        api.nvim_input_mouse('left', 'press', '', 2, 1, 0)
621        screen:expect([[
622        ## grid 1
623          [2:---------------------------------------------]|*2
624          {3:[No Name] [+]                                }|
625          [4:---------------------------------------------]|*3
626          {2:[No Name] [+]                                }|
627          [3:---------------------------------------------]|
628        ## grid 2
629          {7:-}aa                                          |
630          {7:+}{13:^+---  4 lines: bb···························}|
631        ## grid 3
632          :1                                           |
633        ## grid 4
634          {7:-}aa                                          |
635          {7:-}bb                                          |
636          {7:2}cc                                          |
637        ]])
638      else
639        api.nvim_input_mouse('left', 'press', '', 0, 1, 0)
640        screen:expect([[
641          {7:-}aa                                          |
642          {7:+}{13:^+---  4 lines: bb···························}|
643          {3:[No Name] [+]                                }|
644          {7:-}aa                                          |
645          {7:-}bb                                          |
646          {7:2}cc                                          |
647          {2:[No Name] [+]                                }|
648          :1                                           |
649        ]])
650      end
651
652      if multigrid then
653        api.nvim_input_mouse('left', 'press', '', 2, 0, 0)
654        screen:expect([[
655        ## grid 1
656          [2:---------------------------------------------]|*2
657          {3:[No Name] [+]                                }|
658          [4:---------------------------------------------]|*3
659          {2:[No Name] [+]                                }|
660          [3:---------------------------------------------]|
661        ## grid 2
662          {7:+}{13:^+--  6 lines: aa····························}|
663          {1:~                                            }|
664        ## grid 3
665          :1                                           |
666        ## grid 4
667          {7:-}aa                                          |
668          {7:-}bb                                          |
669          {7:2}cc                                          |
670        ]])
671      else
672        api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
673        screen:expect([[
674          {7:+}{13:^+--  6 lines: aa····························}|
675          {1:~                                            }|
676          {3:[No Name] [+]                                }|
677          {7:-}aa                                          |
678          {7:-}bb                                          |
679          {7:2}cc                                          |
680          {2:[No Name] [+]                                }|
681          :1                                           |
682        ]])
683      end
684    end)
685
686    it('with vsplit', function()
687      insert([[
688        aa
689        bb
690        cc
691        dd
692        ee
693        ff]])
694      feed_command('2')
695      command('set foldcolumn=1')
696      feed('zf3j')
697      feed_command('1')
698      feed('zf2j')
699      feed('zO')
700      feed_command('rightbelow vnew')
701      insert([[
702        aa
703        bb
704        cc
705        dd
706        ee
707        ff]])
708      feed_command('2')
709      command('set foldcolumn=1')
710      feed('zf3j')
711      feed_command('1')
712      feed('zf2j')
713      if multigrid then
714        api.nvim_input_mouse('left', 'press', '', 4, 0, 0)
715        screen:expect([[
716        ## grid 1
717          [2:----------------------]{2:│}[4:----------------------]|*6
718          {2:[No Name] [+]          }{3:[No Name] [+]         }|
719          [3:---------------------------------------------]|
720        ## grid 2
721          {7:-}aa                   |
722          {7:-}bb                   |
723          {7:2}cc                   |
724          {7:2}dd                   |
725          {7:2}ee                   |
726          {7:│}ff                   |
727        ## grid 3
728          :1                                           |
729        ## grid 4
730          {7:-}^aa                   |
731          {7:+}{13:+---  4 lines: bb····}|
732          {7:│}ff                   |
733          {1:~                     }|*3
734        ]])
735      else
736        api.nvim_input_mouse('left', 'press', '', 0, 0, 23)
737        screen:expect([[
738          {7:-}aa                   {2:│}{7:-}^aa                   |
739          {7:-}bb                   {2:│}{7:+}{13:+---  4 lines: bb····}|
740          {7:2}cc                   {2:│}{7:│}ff                   |
741          {7:2}dd                   {2:│}{1:~                     }|
742          {7:2}ee                   {2:│}{1:~                     }|
743          {7:│}ff                   {2:│}{1:~                     }|
744          {2:[No Name] [+]          }{3:[No Name] [+]         }|
745          :1                                           |
746        ]])
747      end
748
749      if multigrid then
750        api.nvim_input_mouse('left', 'press', '', 4, 1, 0)
751        screen:expect([[
752        ## grid 1
753          [2:----------------------]{2:│}[4:----------------------]|*6
754          {2:[No Name] [+]          }{3:[No Name] [+]         }|
755          [3:---------------------------------------------]|
756        ## grid 2
757          {7:-}aa                   |
758          {7:-}bb                   |
759          {7:2}cc                   |
760          {7:2}dd                   |
761          {7:2}ee                   |
762          {7:│}ff                   |
763        ## grid 3
764          :1                                           |
765        ## grid 4
766          {7:-}^aa                   |
767          {7:-}bb                   |
768          {7:2}cc                   |
769          {7:2}dd                   |
770          {7:2}ee                   |
771          {7:│}ff                   |
772        ]])
773      else
774        api.nvim_input_mouse('left', 'press', '', 0, 1, 23)
775        screen:expect([[
776          {7:-}aa                   {2:│}{7:-}^aa                   |
777          {7:-}bb                   {2:│}{7:-}bb                   |
778          {7:2}cc                   {2:│}{7:2}cc                   |
779          {7:2}dd                   {2:│}{7:2}dd                   |
780          {7:2}ee                   {2:│}{7:2}ee                   |
781          {7:│}ff                   {2:│}{7:│}ff                   |
782          {2:[No Name] [+]          }{3:[No Name] [+]         }|
783          :1                                           |
784        ]])
785      end
786
787      if multigrid then
788        api.nvim_input_mouse('left', 'press', '', 2, 1, 0)
789        screen:expect([[
790        ## grid 1
791          [2:----------------------]{2:│}[4:----------------------]|*6
792          {3:[No Name] [+]          }{2:[No Name] [+]         }|
793          [3:---------------------------------------------]|
794        ## grid 2
795          {7:-}aa                   |
796          {7:+}{13:^+---  4 lines: bb····}|
797          {7:│}ff                   |
798          {1:~                     }|*3
799        ## grid 3
800          :1                                           |
801        ## grid 4
802          {7:-}aa                   |
803          {7:-}bb                   |
804          {7:2}cc                   |
805          {7:2}dd                   |
806          {7:2}ee                   |
807          {7:│}ff                   |
808        ]])
809      else
810        api.nvim_input_mouse('left', 'press', '', 0, 1, 0)
811        screen:expect([[
812          {7:-}aa                   {2:│}{7:-}aa                   |
813          {7:+}{13:^+---  4 lines: bb····}{2:│}{7:-}bb                   |
814          {7:│}ff                   {2:│}{7:2}cc                   |
815          {1:~                     }{2:│}{7:2}dd                   |
816          {1:~                     }{2:│}{7:2}ee                   |
817          {1:~                     }{2:│}{7:│}ff                   |
818          {3:[No Name] [+]          }{2:[No Name] [+]         }|
819          :1                                           |
820        ]])
821      end
822
823      if multigrid then
824        api.nvim_input_mouse('left', 'press', '', 2, 0, 0)
825        screen:expect([[
826        ## grid 1
827          [2:----------------------]{2:│}[4:----------------------]|*6
828          {3:[No Name] [+]          }{2:[No Name] [+]         }|
829          [3:---------------------------------------------]|
830        ## grid 2
831          {7:+}{13:^+--  6 lines: aa·····}|
832          {1:~                     }|*5
833        ## grid 3
834          :1                                           |
835        ## grid 4
836          {7:-}aa                   |
837          {7:-}bb                   |
838          {7:2}cc                   |
839          {7:2}dd                   |
840          {7:2}ee                   |
841          {7:│}ff                   |
842        ]])
843      else
844        api.nvim_input_mouse('left', 'press', '', 0, 0, 0)
845        screen:expect([[
846          {7:+}{13:^+--  6 lines: aa·····}{2:│}{7:-}aa                   |
847          {1:~                     }{2:│}{7:-}bb                   |
848          {1:~                     }{2:│}{7:2}cc                   |
849          {1:~                     }{2:│}{7:2}dd                   |
850          {1:~                     }{2:│}{7:2}ee                   |
851          {1:~                     }{2:│}{7:│}ff                   |
852          {3:[No Name] [+]          }{2:[No Name] [+]         }|
853          :1                                           |
854        ]])
855      end
856    end)
857
858    it('with tabpages', function()
859      insert([[
860        aa
861        bb
862        cc
863        dd
864        ee
865        ff]])
866      feed_command('2')
867      command('set foldcolumn=2')
868      feed('zf3j')
869      feed_command('1')
870      feed('zf2j')
871      feed('zO')
872      feed_command('tab split')
873      if multigrid then
874        api.nvim_input_mouse('left', 'press', '', 4, 1, 1)
875        screen:expect([[
876        ## grid 1
877          {24: + [No Name] }{5: + [No Name] }{2:                  }{24:X}|
878          [4:---------------------------------------------]|*6
879          [3:---------------------------------------------]|
880        ## grid 2 (hidden)
881          {7:- }aa                                         |
882          {7:│-}bb                                         |
883          {7:││}cc                                         |
884          {7:││}dd                                         |
885          {7:││}ee                                         |
886          {7:│ }ff                                         |
887          {1:~                                            }|
888        ## grid 3
889          :tab split                                   |
890        ## grid 4
891          {7:- }^aa                                         |
892          {7:│+}{13:+---  4 lines: bb··························}|
893          {7:│ }ff                                         |
894          {1:~                                            }|*3
895        ]])
896      else
897        api.nvim_input_mouse('left', 'press', '', 0, 2, 1)
898        screen:expect([[
899          {24: + [No Name] }{5: + [No Name] }{2:                  }{24:X}|
900          {7:- }^aa                                         |
901          {7:│+}{13:+---  4 lines: bb··························}|
902          {7:│ }ff                                         |
903          {1:~                                            }|*3
904          :tab split                                   |
905        ]])
906      end
907
908      if multigrid then
909        api.nvim_input_mouse('left', 'press', '', 4, 0, 0)
910        screen:expect([[
911        ## grid 1
912          {24: + [No Name] }{5: + [No Name] }{2:                  }{24:X}|
913          [4:---------------------------------------------]|*6
914          [3:---------------------------------------------]|
915        ## grid 2 (hidden)
916          {7:- }aa                                         |
917          {7:│-}bb                                         |
918          {7:││}cc                                         |
919          {7:││}dd                                         |
920          {7:││}ee                                         |
921          {7:│ }ff                                         |
922          {1:~                                            }|
923        ## grid 3
924          :tab split                                   |
925        ## grid 4
926          {7:+ }{13:^+--  6 lines: aa···························}|
927          {1:~                                            }|*5
928        ]])
929      else
930        api.nvim_input_mouse('left', 'press', '', 0, 1, 0)
931        screen:expect([[
932          {24: + [No Name] }{5: + [No Name] }{2:                  }{24:X}|
933          {7:+ }{13:^+--  6 lines: aa···························}|
934          {1:~                                            }|*5
935          :tab split                                   |
936        ]])
937      end
938
939      feed_command('tabnext')
940      if multigrid then
941        api.nvim_input_mouse('left', 'press', '', 2, 1, 1)
942        screen:expect([[
943        ## grid 1
944          {5: + [No Name] }{24: + [No Name] }{2:                  }{24:X}|
945          [2:---------------------------------------------]|*6
946          [3:---------------------------------------------]|
947        ## grid 2
948          {7:- }^aa                                         |
949          {7:│+}{13:+---  4 lines: bb··························}|
950          {7:│ }ff                                         |
951          {1:~                                            }|*3
952        ## grid 3
953          :tabnext                                     |
954        ## grid 4 (hidden)
955          {7:+ }{13:+--  6 lines: aa···························}|
956          {1:~                                            }|*5
957        ]])
958      else
959        api.nvim_input_mouse('left', 'press', '', 0, 2, 1)
960        screen:expect([[
961          {5: + [No Name] }{24: + [No Name] }{2:                  }{24:X}|
962          {7:- }^aa                                         |
963          {7:│+}{13:+---  4 lines: bb··························}|
964          {7:│ }ff                                         |
965          {1:~                                            }|*3
966          :tabnext                                     |
967        ]])
968      end
969
970      if multigrid then
971        api.nvim_input_mouse('left', 'press', '', 2, 0, 0)
972        screen:expect([[
973        ## grid 1
974          {5: + [No Name] }{24: + [No Name] }{2:                  }{24:X}|
975          [2:---------------------------------------------]|*6
976          [3:---------------------------------------------]|
977        ## grid 2
978          {7:+ }{13:^+--  6 lines: aa···························}|
979          {1:~                                            }|*5
980        ## grid 3
981          :tabnext                                     |
982        ## grid 4 (hidden)
983          {7:+ }{13:+--  6 lines: aa···························}|
984          {1:~                                            }|*5
985        ]])
986      else
987        api.nvim_input_mouse('left', 'press', '', 0, 1, 0)
988        screen:expect([[
989          {5: + [No Name] }{24: + [No Name] }{2:                  }{24:X}|
990          {7:+ }{13:^+--  6 lines: aa···························}|
991          {1:~                                            }|*5
992          :tabnext                                     |
993        ]])
994      end
995    end)
996
997    it('with multibyte text', function()
998      eq(true, api.nvim_get_option_value('arabicshape', {}))
999      insert([[
1000        å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة
1001        möre text]])
1002      if multigrid then
1003        screen:expect([[
1004        ## grid 1
1005          [2:---------------------------------------------]|*7
1006          [3:---------------------------------------------]|
1007        ## grid 2
1008          å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ                               |
1009          möre tex^t                                    |
1010          {1:~                                            }|*5
1011        ## grid 3
1012                                                       |
1013        ]])
1014      else
1015        screen:expect([[
1016          å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ                               |
1017          möre tex^t                                    |
1018          {1:~                                            }|*5
1019                                                       |
1020        ]])
1021      end
1022
1023      feed('vkzf')
1024      if multigrid then
1025        screen:expect([[
1026        ## grid 1
1027          [2:---------------------------------------------]|*7
1028          [3:---------------------------------------------]|
1029        ## grid 2
1030          {13:^+--  2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}|
1031          {1:~                                            }|*6
1032        ## grid 3
1033                                                       |
1034        ]])
1035      else
1036        screen:expect([[
1037          {13:^+--  2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}|
1038          {1:~                                            }|*6
1039                                                       |
1040        ]])
1041      end
1042
1043      feed_command('set noarabicshape')
1044      if multigrid then
1045        screen:expect([[
1046        ## grid 1
1047          [2:---------------------------------------------]|*7
1048          [3:---------------------------------------------]|
1049        ## grid 2
1050          {13:^+--  2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}|
1051          {1:~                                            }|*6
1052        ## grid 3
1053          :set noarabicshape                           |
1054        ]])
1055      else
1056        screen:expect([[
1057          {13:^+--  2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}|
1058          {1:~                                            }|*6
1059          :set noarabicshape                           |
1060        ]])
1061      end
1062
1063      feed_command('set number foldcolumn=2')
1064      if multigrid then
1065        screen:expect([[
1066        ## grid 1
1067          [2:---------------------------------------------]|*7
1068          [3:---------------------------------------------]|
1069        ## grid 2
1070          {7:+ }{8:  1 }{13:^+--  2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}|
1071          {1:~                                            }|*6
1072        ## grid 3
1073          :set number foldcolumn=2                     |
1074        ]])
1075      else
1076        screen:expect([[
1077          {7:+ }{8:  1 }{13:^+--  2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}|
1078          {1:~                                            }|*6
1079          :set number foldcolumn=2                     |
1080        ]])
1081      end
1082
1083      feed_command('set rightleft')
1084      if multigrid then
1085        screen:expect([[
1086        ## grid 1
1087          [2:---------------------------------------------]|*7
1088          [3:---------------------------------------------]|
1089        ## grid 2
1090          {13:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2  --^+}{8: 1  }{7: +}|
1091          {1:                                            ~}|*6
1092        ## grid 3
1093          :set rightleft                               |
1094        ]])
1095      else
1096        screen:expect([[
1097          {13:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2  --^+}{8: 1  }{7: +}|
1098          {1:                                            ~}|*6
1099          :set rightleft                               |
1100        ]])
1101      end
1102
1103      feed_command('set nonumber foldcolumn=0')
1104      if multigrid then
1105        screen:expect([[
1106        ## grid 1
1107          [2:---------------------------------------------]|*7
1108          [3:---------------------------------------------]|
1109        ## grid 2
1110          {13:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2  --^+}|
1111          {1:                                            ~}|*6
1112        ## grid 3
1113          :set nonumber foldcolumn=0                   |
1114        ]])
1115      else
1116        screen:expect([[
1117          {13:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2  --^+}|
1118          {1:                                            ~}|*6
1119          :set nonumber foldcolumn=0                   |
1120        ]])
1121      end
1122
1123      feed_command('set arabicshape')
1124      if multigrid then
1125        screen:expect([[
1126        ## grid 1
1127          [2:---------------------------------------------]|*7
1128          [3:---------------------------------------------]|
1129        ## grid 2
1130          {13:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2  --^+}|
1131          {1:                                            ~}|*6
1132        ## grid 3
1133          :set arabicshape                             |
1134        ]])
1135      else
1136        screen:expect([[
1137          {13:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2  --^+}|
1138          {1:                                            ~}|*6
1139          :set arabicshape                             |
1140        ]])
1141      end
1142
1143      feed('zo')
1144      if multigrid then
1145        screen:expect([[
1146        ## grid 1
1147          [2:---------------------------------------------]|*7
1148          [3:---------------------------------------------]|
1149        ## grid 2
1150                                         ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å|
1151                                              txet eröm|
1152          {1:                                            ~}|*5
1153        ## grid 3
1154          :set arabicshape                             |
1155        ]])
1156      else
1157        screen:expect([[
1158                                         ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å|
1159                                              txet eröm|
1160          {1:                                            ~}|*5
1161          :set arabicshape                             |
1162        ]])
1163      end
1164
1165      feed_command('set noarabicshape')
1166      if multigrid then
1167        screen:expect([[
1168        ## grid 1
1169          [2:---------------------------------------------]|*7
1170          [3:---------------------------------------------]|
1171        ## grid 2
1172                                         ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å|
1173                                              txet eröm|
1174          {1:                                            ~}|*5
1175        ## grid 3
1176          :set noarabicshape                           |
1177        ]])
1178      else
1179        screen:expect([[
1180                                         ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å|
1181                                              txet eröm|
1182          {1:                                            ~}|*5
1183          :set noarabicshape                           |
1184        ]])
1185      end
1186    end)
1187
1188    it('foldcolumn autoresize', function()
1189      fn.setline(1, 'line 1')
1190      fn.setline(2, 'line 2')
1191      fn.setline(3, 'line 3')
1192      fn.setline(4, 'line 4')
1193
1194      feed('zfj')
1195      command('set foldcolumn=0')
1196      if multigrid then
1197        screen:expect([[
1198        ## grid 1
1199          [2:---------------------------------------------]|*7
1200          [3:---------------------------------------------]|
1201        ## grid 2
1202          {13:^+--  2 lines: line 1·························}|
1203          line 3                                       |
1204          line 4                                       |
1205          {1:~                                            }|*4
1206        ## grid 3
1207                                                       |
1208        ]])
1209      else
1210        screen:expect([[
1211          {13:^+--  2 lines: line 1·························}|
1212          line 3                                       |
1213          line 4                                       |
1214          {1:~                                            }|*4
1215                                                       |
1216        ]])
1217      end
1218      -- should adapt to the current nesting of folds (e.g., 1)
1219      command('set foldcolumn=auto:1')
1220      if multigrid then
1221        screen:expect([[
1222        ## grid 1
1223          [2:---------------------------------------------]|*7
1224          [3:---------------------------------------------]|
1225        ## grid 2
1226          {7:+}{13:^+--  2 lines: line 1························}|
1227          {7: }line 3                                      |
1228          {7: }line 4                                      |
1229          {1:~                                            }|*4
1230        ## grid 3
1231                                                       |
1232        ]])
1233      else
1234        screen:expect([[
1235          {7:+}{13:^+--  2 lines: line 1························}|
1236          {7: }line 3                                      |
1237          {7: }line 4                                      |
1238          {1:~                                            }|*4
1239                                                       |
1240        ]])
1241      end
1242      command('set foldcolumn=auto')
1243      if multigrid then
1244        screen:expect {
1245          grid = [[
1246        ## grid 1
1247          [2:---------------------------------------------]|*7
1248          [3:---------------------------------------------]|
1249        ## grid 2
1250          {7:+}{13:^+--  2 lines: line 1························}|
1251          {7: }line 3                                      |
1252          {7: }line 4                                      |
1253          {1:~                                            }|*4
1254        ## grid 3
1255                                                       |
1256        ]],
1257          unchanged = true,
1258        }
1259      else
1260        screen:expect {
1261          grid = [[
1262          {7:+}{13:^+--  2 lines: line 1························}|
1263          {7: }line 3                                      |
1264          {7: }line 4                                      |
1265          {1:~                                            }|*4
1266                                                       |
1267        ]],
1268          unchanged = true,
1269        }
1270      end
1271      -- fdc should not change with a new fold as the maximum is 1
1272      feed('zf3j')
1273
1274      if multigrid then
1275        screen:expect([[
1276        ## grid 1
1277          [2:---------------------------------------------]|*7
1278          [3:---------------------------------------------]|
1279        ## grid 2
1280          {7:+}{13:^+--  4 lines: line 1························}|
1281          {1:~                                            }|*6
1282        ## grid 3
1283                                                       |
1284        ]])
1285      else
1286        screen:expect([[
1287          {7:+}{13:^+--  4 lines: line 1························}|
1288          {1:~                                            }|*6
1289                                                       |
1290        ]])
1291      end
1292
1293      command('set foldcolumn=auto:1')
1294      if multigrid then
1295        screen:expect_unchanged()
1296      end
1297
1298      -- relax the maximum fdc thus fdc should expand to
1299      -- accommodate the current number of folds
1300      command('set foldcolumn=auto:4')
1301      if multigrid then
1302        screen:expect([[
1303        ## grid 1
1304          [2:---------------------------------------------]|*7
1305          [3:---------------------------------------------]|
1306        ## grid 2
1307          {7:+ }{13:^+--  4 lines: line 1·······················}|
1308          {1:~                                            }|*6
1309        ## grid 3
1310                                                       |
1311        ]])
1312      else
1313        screen:expect([[
1314          {7:+ }{13:^+--  4 lines: line 1·······················}|
1315          {1:~                                            }|*6
1316                                                       |
1317        ]])
1318      end
1319    end)
1320
1321    it('no crash when foldtext is longer than columns #12988', function()
1322      exec([[
1323        function! MyFoldText() abort
1324          return repeat('-', &columns + 100)
1325        endfunction
1326      ]])
1327      command('set foldtext=MyFoldText()')
1328      feed('i<cr><esc>')
1329      feed('vkzf')
1330      if multigrid then
1331        screen:expect([[
1332        ## grid 1
1333          [2:---------------------------------------------]|*7
1334          [3:---------------------------------------------]|
1335        ## grid 2
1336          {13:^---------------------------------------------}|
1337          {1:~                                            }|*6
1338        ## grid 3
1339                                                       |
1340        ]])
1341      else
1342        screen:expect([[
1343          {13:^---------------------------------------------}|
1344          {1:~                                            }|*6
1345                                                       |
1346        ]])
1347      end
1348      assert_alive()
1349    end)
1350
1351    it('fold text is shown when text has been scrolled to the right #19123', function()
1352      insert(content1)
1353      command('set number nowrap')
1354      command('3,4fold')
1355      feed('gg')
1356      if multigrid then
1357        screen:expect([[
1358        ## grid 1
1359          [2:---------------------------------------------]|*7
1360          [3:---------------------------------------------]|
1361        ## grid 2
1362          {8:  1 }^This is a                                |
1363          {8:  2 }valid English                            |
1364          {8:  3 }{13:+--  2 lines: sentence composed by·······}|
1365          {8:  5 }in his cave.                             |
1366          {8:  6 }                                         |
1367          {1:~                                            }|*2
1368        ## grid 3
1369                                                       |
1370        ]])
1371      else
1372        screen:expect([[
1373          {8:  1 }^This is a                                |
1374          {8:  2 }valid English                            |
1375          {8:  3 }{13:+--  2 lines: sentence composed by·······}|
1376          {8:  5 }in his cave.                             |
1377          {8:  6 }                                         |
1378          {1:~                                            }|*2
1379                                                       |
1380        ]])
1381      end
1382
1383      feed('zl')
1384      if multigrid then
1385        screen:expect([[
1386        ## grid 1
1387          [2:---------------------------------------------]|*7
1388          [3:---------------------------------------------]|
1389        ## grid 2
1390          {8:  1 }^his is a                                 |
1391          {8:  2 }alid English                             |
1392          {8:  3 }{13:+--  2 lines: sentence composed by·······}|
1393          {8:  5 }n his cave.                              |
1394          {8:  6 }                                         |
1395          {1:~                                            }|*2
1396        ## grid 3
1397                                                       |
1398        ]])
1399      else
1400        screen:expect([[
1401          {8:  1 }^his is a                                 |
1402          {8:  2 }alid English                             |
1403          {8:  3 }{13:+--  2 lines: sentence composed by·······}|
1404          {8:  5 }n his cave.                              |
1405          {8:  6 }                                         |
1406          {1:~                                            }|*2
1407                                                       |
1408        ]])
1409      end
1410
1411      eq({ 0, 1, 2, 0, 2 }, fn.getcurpos())
1412      api.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 2, 4)
1413      eq({ 0, 3, 2, 0, 2 }, fn.getcurpos())
1414      feed('2k')
1415      eq({ 0, 1, 2, 0, 2 }, fn.getcurpos())
1416
1417      api.nvim_set_option_value('foldtext', "'αβγ'", { win = 0 })
1418      -- No crash or memory leak when scrolling beyond end of folded line #33931
1419      fn.append('$', ('!'):rep(100))
1420      feed('G$')
1421      if multigrid then
1422        screen:expect([[
1423        ## grid 1
1424          [2:---------------------------------------------]|*7
1425          [3:---------------------------------------------]|
1426        ## grid 2
1427          {8:  1 }                                         |
1428          {8:  2 }                                         |
1429          {8:  3 }{13:αβγ······································}|
1430          {8:  5 }                                         |
1431          {8:  6 }                                         |
1432          {8:  7 }!!!!!!!!!!!!!!!!!!!!^!                    |
1433          {1:~                                            }|
1434        ## grid 3
1435                                                       |
1436        ]])
1437      else
1438        screen:expect([[
1439          {8:  1 }                                         |
1440          {8:  2 }                                         |
1441          {8:  3 }{13:αβγ······································}|
1442          {8:  5 }                                         |
1443          {8:  6 }                                         |
1444          {8:  7 }!!!!!!!!!!!!!!!!!!!!^!                    |
1445          {1:~                                            }|
1446                                                       |
1447        ]])
1448      end
1449    end)
1450
1451    it('fold attached virtual lines are drawn and scrolled correctly #21837', function()
1452      fn.setline(1, 'line 1')
1453      fn.setline(2, 'line 2')
1454      fn.setline(3, 'line 3')
1455      fn.setline(4, 'line 4')
1456      feed('zfj')
1457      local ns = api.nvim_create_namespace('ns')
1458      api.nvim_buf_set_extmark(
1459        0,
1460        ns,
1461        0,
1462        0,
1463        { virt_lines_above = true, virt_lines = { { { 'virt_line above line 1', '' } } } }
1464      )
1465      api.nvim_buf_set_extmark(
1466        0,
1467        ns,
1468        1,
1469        0,
1470        { virt_lines = { { { 'virt_line below line 2', '' } } } }
1471      )
1472      api.nvim_buf_set_extmark(
1473        0,
1474        ns,
1475        2,
1476        0,
1477        { virt_lines_above = true, virt_lines = { { { 'virt_line above line 3', '' } } } }
1478      )
1479      api.nvim_buf_set_extmark(
1480        0,
1481        ns,
1482        3,
1483        0,
1484        { virt_lines = { { { 'virt_line below line 4', '' } } } }
1485      )
1486      if multigrid then
1487        screen:expect {
1488          grid = [[
1489        ## grid 1
1490          [2:---------------------------------------------]|*7
1491          [3:---------------------------------------------]|
1492        ## grid 2
1493          {13:^+--  2 lines: line 1·························}|
1494          virt_line above line 3                       |
1495          line 3                                       |
1496          line 4                                       |
1497          virt_line below line 4                       |
1498          {1:~                                            }|*2
1499        ## grid 3
1500                                                       |
1501        ]],
1502          win_viewport = {
1503            [2] = {
1504              win = 1000,
1505              topline = 0,
1506              botline = 5,
1507              curline = 0,
1508              curcol = 0,
1509              linecount = 4,
1510              sum_scroll_delta = 0,
1511            },
1512          },
1513        }
1514      else
1515        screen:expect([[
1516          {13:^+--  2 lines: line 1·························}|
1517          virt_line above line 3                       |
1518          line 3                                       |
1519          line 4                                       |
1520          virt_line below line 4                       |
1521          {1:~                                            }|*2
1522                                                       |
1523        ]])
1524      end
1525
1526      feed('jzfj')
1527      if multigrid then
1528        screen:expect {
1529          grid = [[
1530        ## grid 1
1531          [2:---------------------------------------------]|*7
1532          [3:---------------------------------------------]|
1533        ## grid 2
1534          {13:+--  2 lines: line 1·························}|
1535          {13:^+--  2 lines: line 3·························}|
1536          {1:~                                            }|*5
1537        ## grid 3
1538                                                       |
1539        ]],
1540          win_viewport = {
1541            [2] = {
1542              win = 1000,
1543              topline = 0,
1544              botline = 5,
1545              curline = 2,
1546              curcol = 0,
1547              linecount = 4,
1548              sum_scroll_delta = 0,
1549            },
1550          },
1551        }
1552      else
1553        screen:expect([[
1554          {13:+--  2 lines: line 1·························}|
1555          {13:^+--  2 lines: line 3·························}|
1556          {1:~                                            }|*5
1557                                                       |
1558        ]])
1559      end
1560
1561      feed('kzo<C-Y>')
1562      fn.setline(5, 'line 5')
1563      if multigrid then
1564        screen:expect {
1565          grid = [[
1566        ## grid 1
1567          [2:---------------------------------------------]|*7
1568          [3:---------------------------------------------]|
1569        ## grid 2
1570          virt_line above line 1                       |
1571          ^line 1                                       |
1572          line 2                                       |
1573          virt_line below line 2                       |
1574          {13:+--  2 lines: line 3·························}|
1575          line 5                                       |
1576          {1:~                                            }|
1577        ## grid 3
1578                                                       |
1579        ]],
1580          win_viewport = {
1581            [2] = {
1582              win = 1000,
1583              topline = 0,
1584              botline = 6,
1585              curline = 0,
1586              curcol = 0,
1587              linecount = 5,
1588              sum_scroll_delta = -1,
1589            },
1590          },
1591        }
1592      else
1593        screen:expect([[
1594          virt_line above line 1                       |
1595          ^line 1                                       |
1596          line 2                                       |
1597          virt_line below line 2                       |
1598          {13:+--  2 lines: line 3·························}|
1599          line 5                                       |
1600          {1:~                                            }|
1601                                                       |
1602        ]])
1603      end
1604
1605      api.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0)
1606      eq({
1607        screencol = 1,
1608        screenrow = 5,
1609        winid = 1000,
1610        wincol = 1,
1611        winrow = 5,
1612        line = 3,
1613        column = 1,
1614        coladd = 0,
1615      }, fn.getmousepos())
1616
1617      api.nvim_buf_set_extmark(
1618        0,
1619        ns,
1620        1,
1621        0,
1622        { virt_lines = { { { 'more virt_line below line 2', '' } } } }
1623      )
1624      feed('G<C-E>')
1625      if multigrid then
1626        screen:expect {
1627          grid = [[
1628        ## grid 1
1629          [2:---------------------------------------------]|*7
1630          [3:---------------------------------------------]|
1631        ## grid 2
1632          line 1                                       |
1633          line 2                                       |
1634          virt_line below line 2                       |
1635          more virt_line below line 2                  |
1636          {13:+--  2 lines: line 3·························}|
1637          ^line 5                                       |
1638          {1:~                                            }|
1639        ## grid 3
1640                                                       |
1641        ]],
1642          win_viewport = {
1643            [2] = {
1644              win = 1000,
1645              topline = 0,
1646              botline = 6,
1647              curline = 4,
1648              curcol = 0,
1649              linecount = 5,
1650              sum_scroll_delta = 0,
1651            },
1652          },
1653        }
1654      else
1655        screen:expect([[
1656          line 1                                       |
1657          line 2                                       |
1658          virt_line below line 2                       |
1659          more virt_line below line 2                  |
1660          {13:+--  2 lines: line 3·························}|
1661          ^line 5                                       |
1662          {1:~                                            }|
1663                                                       |
1664        ]])
1665      end
1666
1667      feed('<C-E>')
1668      if multigrid then
1669        screen:expect {
1670          grid = [[
1671        ## grid 1
1672          [2:---------------------------------------------]|*7
1673          [3:---------------------------------------------]|
1674        ## grid 2
1675          line 2                                       |
1676          virt_line below line 2                       |
1677          more virt_line below line 2                  |
1678          {13:+--  2 lines: line 3·························}|
1679          ^line 5                                       |
1680          {1:~                                            }|*2
1681        ## grid 3
1682                                                       |
1683        ]],
1684          win_viewport = {
1685            [2] = {
1686              win = 1000,
1687              topline = 1,
1688              botline = 6,
1689              curline = 4,
1690              curcol = 0,
1691              linecount = 5,
1692              sum_scroll_delta = 1,
1693            },
1694          },
1695        }
1696      else
1697        screen:expect([[
1698          line 2                                       |
1699          virt_line below line 2                       |
1700          more virt_line below line 2                  |
1701          {13:+--  2 lines: line 3·························}|
1702          ^line 5                                       |
1703          {1:~                                            }|*2
1704                                                       |
1705        ]])
1706      end
1707
1708      feed('<C-E>')
1709      if multigrid then
1710        screen:expect {
1711          grid = [[
1712        ## grid 1
1713          [2:---------------------------------------------]|*7
1714          [3:---------------------------------------------]|
1715        ## grid 2
1716          virt_line below line 2                       |
1717          more virt_line below line 2                  |
1718          {13:+--  2 lines: line 3·························}|
1719          ^line 5                                       |
1720          {1:~                                            }|*3
1721        ## grid 3
1722                                                       |
1723        ]],
1724          win_viewport = {
1725            [2] = {
1726              win = 1000,
1727              topline = 2,
1728              botline = 6,
1729              curline = 4,
1730              curcol = 0,
1731              linecount = 5,
1732              sum_scroll_delta = 2,
1733            },
1734          },
1735        }
1736      else
1737        screen:expect([[
1738          virt_line below line 2                       |
1739          more virt_line below line 2                  |
1740          {13:+--  2 lines: line 3·························}|
1741          ^line 5                                       |
1742          {1:~                                            }|*3
1743                                                       |
1744        ]])
1745      end
1746
1747      feed('<C-E>')
1748      if multigrid then
1749        screen:expect {
1750          grid = [[
1751        ## grid 1
1752          [2:---------------------------------------------]|*7
1753          [3:---------------------------------------------]|
1754        ## grid 2
1755          more virt_line below line 2                  |
1756          {13:+--  2 lines: line 3·························}|
1757          ^line 5                                       |
1758          {1:~                                            }|*4
1759        ## grid 3
1760                                                       |
1761        ]],
1762          win_viewport = {
1763            [2] = {
1764              win = 1000,
1765              topline = 2,
1766              botline = 6,
1767              curline = 4,
1768              curcol = 0,
1769              linecount = 5,
1770              sum_scroll_delta = 3,
1771            },
1772          },
1773        }
1774      else
1775        screen:expect([[
1776          more virt_line below line 2                  |
1777          {13:+--  2 lines: line 3·························}|
1778          ^line 5                                       |
1779          {1:~                                            }|*4
1780                                                       |
1781        ]])
1782      end
1783
1784      feed('<C-E>')
1785      if multigrid then
1786        screen:expect {
1787          grid = [[
1788        ## grid 1
1789          [2:---------------------------------------------]|*7
1790          [3:---------------------------------------------]|
1791        ## grid 2
1792          {13:+--  2 lines: line 3·························}|
1793          ^line 5                                       |
1794          {1:~                                            }|*5
1795        ## grid 3
1796                                                       |
1797        ]],
1798          win_viewport = {
1799            [2] = {
1800              win = 1000,
1801              topline = 2,
1802              botline = 6,
1803              curline = 4,
1804              curcol = 0,
1805              linecount = 5,
1806              sum_scroll_delta = 4,
1807            },
1808          },
1809        }
1810      else
1811        screen:expect([[
1812          {13:+--  2 lines: line 3·························}|
1813          ^line 5                                       |
1814          {1:~                                            }|*5
1815                                                       |
1816        ]])
1817      end
1818
1819      feed('<C-E>')
1820      if multigrid then
1821        screen:expect {
1822          grid = [[
1823        ## grid 1
1824          [2:---------------------------------------------]|*7
1825          [3:---------------------------------------------]|
1826        ## grid 2
1827          ^line 5                                       |
1828          {1:~                                            }|*6
1829        ## grid 3
1830                                                       |
1831        ]],
1832          win_viewport = {
1833            [2] = {
1834              win = 1000,
1835              topline = 4,
1836              botline = 6,
1837              curline = 4,
1838              curcol = 0,
1839              linecount = 5,
1840              sum_scroll_delta = 5,
1841            },
1842          },
1843        }
1844      else
1845        screen:expect([[
1846          ^line 5                                       |
1847          {1:~                                            }|*6
1848                                                       |
1849        ]])
1850      end
1851
1852      feed('3<C-Y>')
1853      if multigrid then
1854        screen:expect {
1855          grid = [[
1856        ## grid 1
1857          [2:---------------------------------------------]|*7
1858          [3:---------------------------------------------]|
1859        ## grid 2
1860          virt_line below line 2                       |
1861          more virt_line below line 2                  |
1862          {13:+--  2 lines: line 3·························}|
1863          ^line 5                                       |
1864          {1:~                                            }|*3
1865        ## grid 3
1866                                                       |
1867        ]],
1868          win_viewport = {
1869            [2] = {
1870              win = 1000,
1871              topline = 2,
1872              botline = 6,
1873              curline = 4,
1874              curcol = 0,
1875              linecount = 5,
1876              sum_scroll_delta = 2,
1877            },
1878          },
1879        }
1880      else
1881        screen:expect([[
1882          virt_line below line 2                       |
1883          more virt_line below line 2                  |
1884          {13:+--  2 lines: line 3·························}|
1885          ^line 5                                       |
1886          {1:~                                            }|*3
1887                                                       |
1888        ]])
1889      end
1890
1891      api.nvim_input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0)
1892      if multigrid then
1893        screen:expect {
1894          grid = [[
1895          ## grid 1
1896            [2:---------------------------------------------]|*7
1897            [3:---------------------------------------------]|
1898          ## grid 2
1899            virt_line below line 2                       |
1900            more virt_line below line 2                  |
1901            {13:+--  2 lines: line 3·························}|
1902            {17:^line 5}                                       |
1903            {1:~                                            }|*3
1904          ## grid 3
1905            {5:-- VISUAL LINE --}                            |
1906          ]],
1907          win_viewport = {
1908            [2] = {
1909              win = 1000,
1910              topline = 2,
1911              botline = 6,
1912              curline = 4,
1913              curcol = 0,
1914              linecount = 5,
1915              sum_scroll_delta = 2,
1916            },
1917          },
1918        }
1919      else
1920        screen:expect([[
1921          virt_line below line 2                       |
1922          more virt_line below line 2                  |
1923          {13:+--  2 lines: line 3·························}|
1924          {17:^line 5}                                       |
1925          {1:~                                            }|*3
1926          {5:-- VISUAL LINE --}                            |
1927        ]])
1928      end
1929
1930      api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0)
1931      if multigrid then
1932        screen:expect {
1933          grid = [[
1934          ## grid 1
1935            [2:---------------------------------------------]|*7
1936            [3:---------------------------------------------]|
1937          ## grid 2
1938            more virt_line below line 2                  |
1939            {13:+--  2 lines: line 3·························}|
1940            {17:^line 5}                                       |
1941            {1:~                                            }|*4
1942          ## grid 3
1943            {5:-- VISUAL LINE --}                            |
1944          ]],
1945          win_viewport = {
1946            [2] = {
1947              win = 1000,
1948              topline = 2,
1949              botline = 6,
1950              curline = 4,
1951              curcol = 0,
1952              linecount = 5,
1953              sum_scroll_delta = 3,
1954            },
1955          },
1956        }
1957      else
1958        screen:expect([[
1959          more virt_line below line 2                  |
1960          {13:+--  2 lines: line 3·························}|
1961          {17:^line 5}                                       |
1962          {1:~                                            }|*4
1963          {5:-- VISUAL LINE --}                            |
1964        ]])
1965      end
1966
1967      api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5)
1968      if multigrid then
1969        screen:expect {
1970          grid = [[
1971          ## grid 1
1972            [2:---------------------------------------------]|*7
1973            [3:---------------------------------------------]|
1974          ## grid 2
1975            {13:+--  2 lines: line 3·························}|
1976            {17:line ^5}                                       |
1977            {1:~                                            }|*5
1978          ## grid 3
1979            {5:-- VISUAL LINE --}                            |
1980          ]],
1981          win_viewport = {
1982            [2] = {
1983              win = 1000,
1984              topline = 2,
1985              botline = 6,
1986              curline = 4,
1987              curcol = 5,
1988              linecount = 5,
1989              sum_scroll_delta = 4,
1990            },
1991          },
1992        }
1993      else
1994        screen:expect([[
1995          {13:+--  2 lines: line 3·························}|
1996          {17:line ^5}                                       |
1997          {1:~                                            }|*5
1998          {5:-- VISUAL LINE --}                            |
1999        ]])
2000      end
2001
2002      feed('<Esc>gg')
2003      command('botright 1split | wincmd w')
2004      if multigrid then
2005        screen:expect {
2006          grid = [[
2007          ## grid 1
2008            [2:---------------------------------------------]|*4
2009            {3:[No Name] [+]                                }|
2010            [4:---------------------------------------------]|
2011            {2:[No Name] [+]                                }|
2012            [3:---------------------------------------------]|
2013          ## grid 2
2014            ^line 1                                       |
2015            line 2                                       |
2016            virt_line below line 2                       |
2017            more virt_line below line 2                  |
2018          ## grid 3
2019                                                         |
2020          ## grid 4
2021            line 1                                       |
2022          ]],
2023          win_viewport = {
2024            [2] = {
2025              win = 1000,
2026              topline = 0,
2027              botline = 3,
2028              curline = 0,
2029              curcol = 0,
2030              linecount = 5,
2031              sum_scroll_delta = 0,
2032            },
2033            [4] = {
2034              win = 1001,
2035              topline = 0,
2036              botline = 2,
2037              curline = 0,
2038              curcol = 0,
2039              linecount = 5,
2040              sum_scroll_delta = 0,
2041            },
2042          },
2043        }
2044      else
2045        screen:expect([[
2046          ^line 1                                       |
2047          line 2                                       |
2048          virt_line below line 2                       |
2049          more virt_line below line 2                  |
2050          {3:[No Name] [+]                                }|
2051          line 1                                       |
2052          {2:[No Name] [+]                                }|
2053                                                       |
2054        ]])
2055      end
2056
2057      feed('<C-Y>')
2058      if multigrid then
2059        screen:expect {
2060          grid = [[
2061        ## grid 1
2062          [2:---------------------------------------------]|*4
2063          {3:[No Name] [+]                                }|
2064          [4:---------------------------------------------]|
2065          {2:[No Name] [+]                                }|
2066          [3:---------------------------------------------]|
2067        ## grid 2
2068          virt_line above line 1                       |
2069          ^line 1                                       |
2070          line 2                                       |
2071          virt_line below line 2                       |
2072        ## grid 3
2073                                                       |
2074        ## grid 4
2075          line 1                                       |
2076        ]],
2077          win_viewport = {
2078            [2] = {
2079              win = 1000,
2080              topline = 0,
2081              botline = 3,
2082              curline = 0,
2083              curcol = 0,
2084              linecount = 5,
2085              sum_scroll_delta = -1,
2086            },
2087            [4] = {
2088              win = 1001,
2089              topline = 0,
2090              botline = 2,
2091              curline = 0,
2092              curcol = 0,
2093              linecount = 5,
2094              sum_scroll_delta = 0,
2095            },
2096          },
2097        }
2098      else
2099        screen:expect([[
2100          virt_line above line 1                       |
2101          ^line 1                                       |
2102          line 2                                       |
2103          virt_line below line 2                       |
2104          {3:[No Name] [+]                                }|
2105          line 1                                       |
2106          {2:[No Name] [+]                                }|
2107                                                       |
2108        ]])
2109      end
2110    end)
2111
2112    it('virt_lines above line where fold begins do not duplicate foldcolumn', function()
2113      fn.setline(1, 'line 1')
2114      fn.setline(2, 'line 2')
2115      fn.setline(3, 'line 3')
2116      fn.setline(4, 'line 4')
2117
2118      local ns = api.nvim_create_namespace('ns')
2119      api.nvim_buf_set_extmark(
2120        0,
2121        ns,
2122        1,
2123        0,
2124        { virt_lines_above = true, virt_lines = { { { 'above line 2' } } } }
2125      )
2126      api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_lines = { { { 'below line 3' } } } })
2127
2128      command('set foldcolumn=1')
2129      feed('jzfl')
2130      feed('2jzfl')
2131      if multigrid then
2132        screen:expect([[
2133        ## grid 1
2134          [2:---------------------------------------------]|*7
2135          [3:---------------------------------------------]|
2136        ## grid 2
2137          {7: }line 1                                      |
2138          {7: }above line 2                                |
2139          {7:-}line 2                                      |
2140          {7: }line 3                                      |
2141          {7: }below line 3                                |
2142          {7:-}^line 4                                      |
2143          {1:~                                            }|
2144        ## grid 3
2145                                                       |
2146        ]])
2147      else
2148        screen:expect([[
2149          {7: }line 1                                      |
2150          {7: }above line 2                                |
2151          {7:-}line 2                                      |
2152          {7: }line 3                                      |
2153          {7: }below line 3                                |
2154          {7:-}^line 4                                      |
2155          {1:~                                            }|
2156                                                       |
2157        ]])
2158      end
2159
2160      -- `foldcolumn` in `statuscolumn` should be identical
2161      command('set statuscolumn=%C')
2162      screen:expect_unchanged()
2163    end)
2164
2165    it('foldcolumn is not interrupted when virt_lines are inside a fold', function()
2166      fn.setline(1, 'line 1')
2167      fn.setline(2, 'line 2')
2168      fn.setline(3, 'line 3')
2169      fn.setline(4, 'line 4')
2170
2171      local ns = api.nvim_create_namespace('ns')
2172      api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_lines = { { { 'below line 2', '' } } } })
2173      api.nvim_buf_set_extmark(
2174        0,
2175        ns,
2176        2,
2177        0,
2178        { virt_lines_above = true, virt_lines = { { { 'above line 3', '' } } } }
2179      )
2180
2181      command('set foldcolumn=1')
2182      feed('zf2j')
2183      feed('zo')
2184      if multigrid then
2185        screen:expect([[
2186        ## grid 1
2187          [2:---------------------------------------------]|*7
2188          [3:---------------------------------------------]|
2189        ## grid 2
2190          {7:-}^line 1                                      |
2191          {7:│}line 2                                      |
2192          {7:│}below line 2                                |
2193          {7:│}above line 3                                |
2194          {7:│}line 3                                      |
2195          {7: }line 4                                      |
2196          {1:~                                            }|
2197        ## grid 3
2198                                                       |
2199        ]])
2200      else
2201        screen:expect([[
2202          {7:-}^line 1                                      |
2203          {7:│}line 2                                      |
2204          {7:│}below line 2                                |
2205          {7:│}above line 3                                |
2206          {7:│}line 3                                      |
2207          {7: }line 4                                      |
2208          {1:~                                            }|
2209                                                       |
2210        ]])
2211      end
2212
2213      command('set statuscolumn=%C')
2214      screen:expect_unchanged()
2215    end)
2216
2217    it('foldcolumn for a virt_line above a nested fold shows correct fold level', function()
2218      fn.setline(1, 'line 1')
2219      fn.setline(2, 'line 2')
2220      fn.setline(3, 'line 3')
2221      fn.setline(4, 'line 4')
2222
2223      local ns = api.nvim_create_namespace('ns')
2224      api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_lines = { { { 'below line 2', '' } } } })
2225      api.nvim_buf_set_extmark(
2226        0,
2227        ns,
2228        2,
2229        0,
2230        { virt_lines_above = true, virt_lines = { { { 'above line 3', '' } } } }
2231      )
2232
2233      command('1,4fold | 1,4foldopen')
2234      command('3,4fold | 3,4foldopen ')
2235      command('set foldcolumn=1')
2236      if multigrid then
2237        screen:expect([[
2238        ## grid 1
2239          [2:---------------------------------------------]|*7
2240          [3:---------------------------------------------]|
2241        ## grid 2
2242          {7:-}^line 1                                      |
2243          {7:│}line 2                                      |
2244          {7:│}below line 2                                |
2245          {7:│}above line 3                                |
2246          {7:-}line 3                                      |
2247          {7:2}line 4                                      |
2248          {1:~                                            }|
2249        ## grid 3
2250                                                       |
2251        ]])
2252      else
2253        screen:expect([[
2254          {7:-}^line 1                                      |
2255          {7:│}line 2                                      |
2256          {7:│}below line 2                                |
2257          {7:│}above line 3                                |
2258          {7:-}line 3                                      |
2259          {7:2}line 4                                      |
2260          {1:~                                            }|
2261                                                       |
2262        ]])
2263      end
2264
2265      command('set statuscolumn=%C')
2266      screen:expect_unchanged()
2267      command('set statuscolumn=')
2268
2269      command('set foldcolumn=2')
2270      if multigrid then
2271        screen:expect([[
2272        ## grid 1
2273          [2:---------------------------------------------]|*7
2274          [3:---------------------------------------------]|
2275        ## grid 2
2276          {7:- }^line 1                                     |
2277          {7:│ }line 2                                     |
2278          {7:│ }below line 2                               |
2279          {7:│ }above line 3                               |
2280          {7:│-}line 3                                     |
2281          {7:││}line 4                                     |
2282          {1:~                                            }|
2283        ## grid 3
2284                                                       |
2285        ]])
2286      else
2287        screen:expect([[
2288          {7:- }^line 1                                     |
2289          {7:│ }line 2                                     |
2290          {7:│ }below line 2                               |
2291          {7:│ }above line 3                               |
2292          {7:│-}line 3                                     |
2293          {7:││}line 4                                     |
2294          {1:~                                            }|
2295                                                       |
2296        ]])
2297      end
2298
2299      command('set statuscolumn=%C')
2300      screen:expect_unchanged()
2301      command('set statuscolumn=')
2302
2303      command('2,4fold | 2,4foldopen')
2304      if multigrid then
2305        screen:expect([[
2306        ## grid 1
2307          [2:---------------------------------------------]|*7
2308          [3:---------------------------------------------]|
2309        ## grid 2
2310          {7:- }^line 1                                     |
2311          {7:│-}line 2                                     |
2312          {7:││}below line 2                               |
2313          {7:││}above line 3                               |
2314          {7:2-}line 3                                     |
2315          {7:23}line 4                                     |
2316          {1:~                                            }|
2317        ## grid 3
2318                                                       |
2319        ]])
2320      else
2321        screen:expect([[
2322          {7:- }^line 1                                     |
2323          {7:│-}line 2                                     |
2324          {7:││}below line 2                               |
2325          {7:││}above line 3                               |
2326          {7:2-}line 3                                     |
2327          {7:23}line 4                                     |
2328          {1:~                                            }|
2329                                                       |
2330        ]])
2331      end
2332
2333      command('set statuscolumn=%C')
2334      screen:expect_unchanged()
2335    end)
2336
2337    it('Folded and Visual highlights are combined #19691', function()
2338      command('hi! Visual guifg=NONE guibg=Red')
2339      insert([[
2340        " foofoofoofoofoofoo
2341        " 口 {{{1
2342        set nocp
2343        " }}}1
2344        " barbarbarbarbarbar
2345        " 口 {{{1
2346        set foldmethod=marker
2347        " }}}1
2348        " bazbazbazbazbazbaz]])
2349      feed('gg')
2350      command('source')
2351      feed('<C-V>G15l')
2352      if multigrid then
2353        screen:expect([[
2354        ## grid 1
2355          [2:---------------------------------------------]|*7
2356          [3:---------------------------------------------]|
2357        ## grid 2
2358          {30:" foofoofoofoofo}ofoo                         |
2359          {103:+--  3 lines: " }{13:口···························}|
2360          {30:" barbarbarbarba}rbar                         |
2361          {103:+--  3 lines: " }{13:口···························}|
2362          {30:" bazbazbazbazb^a}zbaz                         |
2363          {1:~                                            }|*2
2364        ## grid 3
2365          {5:-- VISUAL BLOCK --}                           |
2366        ]])
2367      else
2368        screen:expect([[
2369          {30:" foofoofoofoofo}ofoo                         |
2370          {103:+--  3 lines: " }{13:口···························}|
2371          {30:" barbarbarbarba}rbar                         |
2372          {103:+--  3 lines: " }{13:口···························}|
2373          {30:" bazbazbazbazb^a}zbaz                         |
2374          {1:~                                            }|*2
2375          {5:-- VISUAL BLOCK --}                           |
2376        ]])
2377      end
2378
2379      feed('l')
2380      if multigrid then
2381        screen:expect([[
2382        ## grid 1
2383          [2:---------------------------------------------]|*7
2384          [3:---------------------------------------------]|
2385        ## grid 2
2386          {30:" foofoofoofoofoo}foo                         |
2387          {103:+--  3 lines: " 口}{13:···························}|
2388          {30:" barbarbarbarbar}bar                         |
2389          {103:+--  3 lines: " 口}{13:···························}|
2390          {30:" bazbazbazbazba^z}baz                         |
2391          {1:~                                            }|*2
2392        ## grid 3
2393          {5:-- VISUAL BLOCK --}                           |
2394        ]])
2395      else
2396        screen:expect([[
2397          {30:" foofoofoofoofoo}foo                         |
2398          {103:+--  3 lines: " 口}{13:···························}|
2399          {30:" barbarbarbarbar}bar                         |
2400          {103:+--  3 lines: " 口}{13:···························}|
2401          {30:" bazbazbazbazba^z}baz                         |
2402          {1:~                                            }|*2
2403          {5:-- VISUAL BLOCK --}                           |
2404        ]])
2405      end
2406
2407      feed('l')
2408      if multigrid then
2409        screen:expect([[
2410        ## grid 1
2411          [2:---------------------------------------------]|*7
2412          [3:---------------------------------------------]|
2413        ## grid 2
2414          {30:" foofoofoofoofoof}oo                         |
2415          {103:+--  3 lines: " 口}{13:···························}|
2416          {30:" barbarbarbarbarb}ar                         |
2417          {103:+--  3 lines: " 口}{13:···························}|
2418          {30:" bazbazbazbazbaz^b}az                         |
2419          {1:~                                            }|*2
2420        ## grid 3
2421          {5:-- VISUAL BLOCK --}                           |
2422        ]])
2423      else
2424        screen:expect([[
2425          {30:" foofoofoofoofoof}oo                         |
2426          {103:+--  3 lines: " 口}{13:···························}|
2427          {30:" barbarbarbarbarb}ar                         |
2428          {103:+--  3 lines: " 口}{13:···························}|
2429          {30:" bazbazbazbazbaz^b}az                         |
2430          {1:~                                            }|*2
2431          {5:-- VISUAL BLOCK --}                           |
2432        ]])
2433      end
2434
2435      feed('2l')
2436      if multigrid then
2437        screen:expect([[
2438        ## grid 1
2439          [2:---------------------------------------------]|*7
2440          [3:---------------------------------------------]|
2441        ## grid 2
2442          {30:" foofoofoofoofoofoo}                         |
2443          {103:+--  3 lines: " 口··}{13:·························}|
2444          {30:" barbarbarbarbarbar}                         |
2445          {103:+--  3 lines: " 口··}{13:·························}|
2446          {30:" bazbazbazbazbazba^z}                         |
2447          {1:~                                            }|*2
2448        ## grid 3
2449          {5:-- VISUAL BLOCK --}                           |
2450        ]])
2451      else
2452        screen:expect([[
2453          {30:" foofoofoofoofoofoo}                         |
2454          {103:+--  3 lines: " 口··}{13:·························}|
2455          {30:" barbarbarbarbarbar}                         |
2456          {103:+--  3 lines: " 口··}{13:·························}|
2457          {30:" bazbazbazbazbazba^z}                         |
2458          {1:~                                            }|*2
2459          {5:-- VISUAL BLOCK --}                           |
2460        ]])
2461      end
2462
2463      feed('O16l')
2464      if multigrid then
2465        screen:expect([[
2466        ## grid 1
2467          [2:---------------------------------------------]|*7
2468          [3:---------------------------------------------]|
2469        ## grid 2
2470          " foofoofoofoofo{30:ofoo}                         |
2471          {13:+--  3 lines: " }{103:口··}{13:·························}|
2472          " barbarbarbarba{30:rbar}                         |
2473          {13:+--  3 lines: " }{103:口··}{13:·························}|
2474          " bazbazbazbazba{30:^zbaz}                         |
2475          {1:~                                            }|*2
2476        ## grid 3
2477          {5:-- VISUAL BLOCK --}                           |
2478        ]])
2479      else
2480        screen:expect([[
2481          " foofoofoofoofo{30:ofoo}                         |
2482          {13:+--  3 lines: " }{103:口··}{13:·························}|
2483          " barbarbarbarba{30:rbar}                         |
2484          {13:+--  3 lines: " }{103:口··}{13:·························}|
2485          " bazbazbazbazba{30:^zbaz}                         |
2486          {1:~                                            }|*2
2487          {5:-- VISUAL BLOCK --}                           |
2488        ]])
2489      end
2490
2491      feed('l')
2492      if multigrid then
2493        screen:expect([[
2494        ## grid 1
2495          [2:---------------------------------------------]|*7
2496          [3:---------------------------------------------]|
2497        ## grid 2
2498          " foofoofoofoofoo{30:foo}                         |
2499          {13:+--  3 lines: " }{103:口··}{13:·························}|
2500          " barbarbarbarbar{30:bar}                         |
2501          {13:+--  3 lines: " }{103:口··}{13:·························}|
2502          " bazbazbazbazbaz{30:^baz}                         |
2503          {1:~                                            }|*2
2504        ## grid 3
2505          {5:-- VISUAL BLOCK --}                           |
2506        ]])
2507      else
2508        screen:expect([[
2509          " foofoofoofoofoo{30:foo}                         |
2510          {13:+--  3 lines: " }{103:口··}{13:·························}|
2511          " barbarbarbarbar{30:bar}                         |
2512          {13:+--  3 lines: " }{103:口··}{13:·························}|
2513          " bazbazbazbazbaz{30:^baz}                         |
2514          {1:~                                            }|*2
2515          {5:-- VISUAL BLOCK --}                           |
2516        ]])
2517      end
2518    end)
2519
2520    it('do not show search or match highlight #24084', function()
2521      insert([[
2522        line 1
2523        line 2
2524        line 3
2525        line 4]])
2526      command('2,3fold')
2527      feed('/line')
2528      if multigrid then
2529        screen:expect([[
2530        ## grid 1
2531          [2:---------------------------------------------]|*7
2532          [3:---------------------------------------------]|
2533        ## grid 2
2534          {2:line} 1                                       |
2535          {13:+--  2 lines: line 2·························}|
2536          {10:line} 4                                       |
2537          {1:~                                            }|*4
2538        ## grid 3
2539          /line^                                        |
2540        ]])
2541      else
2542        screen:expect([[
2543          {2:line} 1                                       |
2544          {13:+--  2 lines: line 2·························}|
2545          {10:line} 4                                       |
2546          {1:~                                            }|*4
2547          /line^                                        |
2548        ]])
2549      end
2550      feed('<Esc>')
2551      fn.matchadd('Search', 'line')
2552      if multigrid then
2553        screen:expect([[
2554        ## grid 1
2555          [2:---------------------------------------------]|*7
2556          [3:---------------------------------------------]|
2557        ## grid 2
2558          {10:line} 1                                       |
2559          {13:+--  2 lines: line 2·························}|
2560          {10:line} ^4                                       |
2561          {1:~                                            }|*4
2562        ## grid 3
2563                                                       |
2564        ]])
2565      else
2566        screen:expect([[
2567          {10:line} 1                                       |
2568          {13:+--  2 lines: line 2·························}|
2569          {10:line} ^4                                       |
2570          {1:~                                            }|*4
2571                                                       |
2572        ]])
2573      end
2574    end)
2575
2576    it('foldtext with virtual text format', function()
2577      screen:try_resize(30, 7)
2578      insert(content1)
2579      command('hi! CursorLine guibg=NONE guifg=Red gui=NONE')
2580      command('hi F0 guibg=Red guifg=Black')
2581      command('hi F1 guifg=White')
2582      api.nvim_set_option_value('cursorline', true, {})
2583      api.nvim_set_option_value('foldcolumn', '4', {})
2584      api.nvim_set_option_value(
2585        'foldtext',
2586        '['
2587          .. '["▶", ["F0", "F1"]], '
2588          .. '[v:folddashes], '
2589          .. '["\t", "Search"], '
2590          .. '[getline(v:foldstart), "NonText"]]',
2591        {}
2592      )
2593
2594      command('3,4fold')
2595      command('5,6fold')
2596      command('2,6fold')
2597      if multigrid then
2598        screen:expect([[
2599        ## grid 1
2600          [2:------------------------------]|*6
2601          [3:------------------------------]|
2602        ## grid 2
2603          {7:    }This is a                 |
2604          {7:+   }{9:^▶}{101:-}{20:      }{104:valid English}{101:·····}|
2605          {1:~                             }|*4
2606        ## grid 3
2607                                        |
2608        ]])
2609      else
2610        screen:expect([[
2611          {7:    }This is a                 |
2612          {7:+   }{9:^▶}{101:-}{20:      }{104:valid English}{101:·····}|
2613          {1:~                             }|*4
2614                                        |
2615        ]])
2616      end
2617      eq('▶-\tvalid English', fn.foldtextresult(2))
2618
2619      feed('zo')
2620      if multigrid then
2621        screen:expect([[
2622        ## grid 1
2623          [2:------------------------------]|*6
2624          [3:------------------------------]|
2625        ## grid 2
2626          {7:    }This is a                 |
2627          {7:-   }valid English             |
2628          {7:│+  }{9:▶}{13:--}{105:     }{104:sentence composed }|
2629          {7:│+  }{9:^▶}{101:--}{20:     }{104:in his cave.}{101:······}|
2630          {1:~                             }|*2
2631        ## grid 3
2632                                        |
2633        ]])
2634      else
2635        screen:expect([[
2636          {7:    }This is a                 |
2637          {7:-   }valid English             |
2638          {7:│+  }{9:▶}{13:--}{105:     }{104:sentence composed }|
2639          {7:│+  }{9:^▶}{101:--}{20:     }{104:in his cave.}{101:······}|
2640          {1:~                             }|*2
2641                                        |
2642        ]])
2643      end
2644      eq('▶--\tsentence composed by', fn.foldtextresult(3))
2645      eq('▶--\tin his cave.', fn.foldtextresult(5))
2646
2647      command('hi! Visual guifg=NONE guibg=Red')
2648      feed('V2k')
2649      if multigrid then
2650        screen:expect([[
2651        ## grid 1
2652          [2:------------------------------]|*6
2653          [3:------------------------------]|
2654        ## grid 2
2655          {7:    }This is a                 |
2656          {7:-   }{30:^valid English}             |
2657          {7:│+  }{9:▶}{103:--}{105:     }{106:sentence composed }|
2658          {7:│+  }{9:▶}{103:--}{105:     }{106:in his cave.}{103:······}|
2659          {1:~                             }|*2
2660        ## grid 3
2661          {5:-- VISUAL LINE --}             |
2662        ]])
2663      else
2664        screen:expect([[
2665          {7:    }This is a                 |
2666          {7:-   }{30:^valid English}             |
2667          {7:│+  }{9:▶}{103:--}{105:     }{106:sentence composed }|
2668          {7:│+  }{9:▶}{103:--}{105:     }{106:in his cave.}{103:······}|
2669          {1:~                             }|*2
2670          {5:-- VISUAL LINE --}             |
2671        ]])
2672      end
2673
2674      api.nvim_set_option_value('rightleft', true, {})
2675      if multigrid then
2676        screen:expect([[
2677        ## grid 1
2678          [2:------------------------------]|*6
2679          [3:------------------------------]|
2680        ## grid 2
2681                           a si sihT{7:    }|
2682                       {30:hsilgnE dila^v}{7:   -}|
2683          {106: desopmoc ecnetnes}{105:     }{103:--}{9:▶}{7:  +│}|
2684          {103:······}{106:.evac sih ni}{105:     }{103:--}{9:▶}{7:  +│}|
2685          {1:                             ~}|*2
2686        ## grid 3
2687          {5:-- VISUAL LINE --}             |
2688        ]])
2689      else
2690        screen:expect([[
2691                           a si sihT{7:    }|
2692                       {30:hsilgnE dila^v}{7:   -}|
2693          {106: desopmoc ecnetnes}{105:     }{103:--}{9:▶}{7:  +│}|
2694          {103:······}{106:.evac sih ni}{105:     }{103:--}{9:▶}{7:  +│}|
2695          {1:                             ~}|*2
2696          {5:-- VISUAL LINE --}             |
2697        ]])
2698      end
2699    end)
2700
2701    it('transparent foldtext', function()
2702      screen:try_resize(30, 7)
2703      insert(content1)
2704      command('hi! CursorLine guibg=NONE guifg=Red gui=NONE')
2705      command([[syn match Keyword /\<sentence\>/]])
2706      command('hi! Keyword guibg=NONE guifg=Green')
2707      api.nvim_set_option_value('cursorline', true, {})
2708      api.nvim_set_option_value('foldcolumn', '4', {})
2709      api.nvim_set_option_value('foldtext', '', {})
2710
2711      command('3,4fold')
2712      command('5,6fold')
2713      command('2,6fold')
2714      if multigrid then
2715        screen:expect([[
2716        ## grid 1
2717          [2:------------------------------]|*6
2718          [3:------------------------------]|
2719        ## grid 2
2720          {7:    }This is a                 |
2721          {7:+   }{101:^valid English·············}|
2722          {1:~                             }|*4
2723        ## grid 3
2724                                        |
2725        ]])
2726      else
2727        screen:expect([[
2728          {7:    }This is a                 |
2729          {7:+   }{101:^valid English·············}|
2730          {1:~                             }|*4
2731                                        |
2732        ]])
2733      end
2734
2735      feed('zo')
2736      if multigrid then
2737        screen:expect([[
2738        ## grid 1
2739          [2:------------------------------]|*6
2740          [3:------------------------------]|
2741        ## grid 2
2742          {7:    }This is a                 |
2743          {7:-   }valid English             |
2744          {7:│+  }{107:sentence}{13: composed by······}|
2745          {7:│+  }{101:^in his cave.··············}|
2746          {1:~                             }|*2
2747        ## grid 3
2748                                        |
2749        ]])
2750      else
2751        screen:expect([[
2752          {7:    }This is a                 |
2753          {7:-   }valid English             |
2754          {7:│+  }{107:sentence}{13: composed by······}|
2755          {7:│+  }{101:^in his cave.··············}|
2756          {1:~                             }|*2
2757                                        |
2758        ]])
2759      end
2760
2761      command('hi! Visual guifg=NONE guibg=Red')
2762      feed('V2k')
2763      if multigrid then
2764        screen:expect([[
2765        ## grid 1
2766          [2:------------------------------]|*6
2767          [3:------------------------------]|
2768        ## grid 2
2769          {7:    }This is a                 |
2770          {7:-   }{30:^valid English}             |
2771          {7:│+  }{108:sentence}{103: composed by······}|
2772          {7:│+  }{103:in his cave.··············}|
2773          {1:~                             }|*2
2774        ## grid 3
2775          {5:-- VISUAL LINE --}             |
2776        ]])
2777      else
2778        screen:expect([[
2779          {7:    }This is a                 |
2780          {7:-   }{30:^valid English}             |
2781          {7:│+  }{108:sentence}{103: composed by······}|
2782          {7:│+  }{103:in his cave.··············}|
2783          {1:~                             }|*2
2784          {5:-- VISUAL LINE --}             |
2785        ]])
2786      end
2787
2788      api.nvim_set_option_value('rightleft', true, {})
2789      if multigrid then
2790        screen:expect([[
2791        ## grid 1
2792          [2:------------------------------]|*6
2793          [3:------------------------------]|
2794        ## grid 2
2795                           a si sihT{7:    }|
2796                       {30:hsilgnE dila^v}{7:   -}|
2797          {103:······yb desopmoc }{108:ecnetnes}{7:  +│}|
2798          {103:··············.evac sih ni}{7:  +│}|
2799          {1:                             ~}|*2
2800        ## grid 3
2801          {5:-- VISUAL LINE --}             |
2802        ]])
2803      else
2804        screen:expect([[
2805                           a si sihT{7:    }|
2806                       {30:hsilgnE dila^v}{7:   -}|
2807          {103:······yb desopmoc }{108:ecnetnes}{7:  +│}|
2808          {103:··············.evac sih ni}{7:  +│}|
2809          {1:                             ~}|*2
2810          {5:-- VISUAL LINE --}             |
2811        ]])
2812      end
2813
2814      api.nvim_set_option_value('rightleft', false, {})
2815      api.nvim_set_option_value('wrap', false, {})
2816      feed('<Esc>zl')
2817      if multigrid then
2818        screen:expect([[
2819        ## grid 1
2820          [2:------------------------------]|*6
2821          [3:------------------------------]|
2822        ## grid 2
2823          {7:    }his is a                  |
2824          {7:-   }{100:^alid English              }|
2825          {7:│+  }{107:entence}{13: composed by·······}|
2826          {7:│+  }{13:n his cave.···············}|
2827          {1:~                             }|*2
2828        ## grid 3
2829                                        |
2830        ]])
2831      else
2832        screen:expect([[
2833          {7:    }his is a                  |
2834          {7:-   }{100:^alid English              }|
2835          {7:│+  }{107:entence}{13: composed by·······}|
2836          {7:│+  }{13:n his cave.···············}|
2837          {1:~                             }|*2
2838                                        |
2839        ]])
2840      end
2841
2842      fn.append(0, ('!'):rep(15))
2843      feed('gg$zs')
2844      if multigrid then
2845        screen:expect([[
2846        ## grid 1
2847          [2:------------------------------]|*6
2848          [3:------------------------------]|
2849        ## grid 2
2850          {7:    }{100:^!                         }|
2851          {7:    }                          |
2852          {7:-   }                          |
2853          {7:│+  }{13:sed by····················}|
2854          {7:│+  }{13:··························}|
2855          {1:~                             }|
2856        ## grid 3
2857                                        |
2858        ]])
2859      else
2860        screen:expect([[
2861          {7:    }{100:^!                         }|
2862          {7:    }                          |
2863          {7:-   }                          |
2864          {7:│+  }{13:sed by····················}|
2865          {7:│+  }{13:··························}|
2866          {1:~                             }|
2867                                        |
2868        ]])
2869      end
2870    end)
2871
2872    it('transparent foldtext filler text search highlighting', function()
2873      screen:try_resize(30, 7)
2874      insert(content1)
2875      api.nvim_set_option_value('foldtext', '', {})
2876
2877      command("3,4fold | let v:hlsearch = 1 | let @/ = '.'")
2878      if multigrid then
2879        screen:expect([[
2880        ## grid 1
2881          [2:------------------------------]|*6
2882          [3:------------------------------]|
2883        ## grid 2
2884          {10:This is a}                     |
2885          {10:valid English}                 |
2886          {105:sentence composed by}{13:··········}|
2887          {10:in his cave.}                  |
2888          ^                              |
2889          {1:~                             }|
2890        ## grid 3
2891                                        |
2892        ]])
2893      else
2894        screen:expect([[
2895          {10:This is a}                     |
2896          {10:valid English}                 |
2897          {105:sentence composed by}{13:··········}|
2898          {10:in his cave.}                  |
2899          ^                              |
2900          {1:~                             }|
2901                                        |
2902        ]])
2903      end
2904
2905      command("let @/ = '$'")
2906      if multigrid then
2907        screen:expect([[
2908        ## grid 1
2909          [2:------------------------------]|*6
2910          [3:------------------------------]|
2911        ## grid 2
2912          This is a{10: }                    |
2913          valid English{10: }                |
2914          {13:sentence composed by}{105:·}{13:·········}|
2915          in his cave.{10: }                 |
2916          {10:^ }                             |
2917          {1:~                             }|
2918        ## grid 3
2919                                        |
2920        ]])
2921      else
2922        screen:expect([[
2923          This is a{10: }                    |
2924          valid English{10: }                |
2925          {13:sentence composed by}{105:·}{13:·········}|
2926          in his cave.{10: }                 |
2927          {10:^ }                             |
2928          {1:~                             }|
2929                                        |
2930        ]])
2931      end
2932
2933      command("let @/ = '.\\?'")
2934      if multigrid then
2935        screen:expect([[
2936        ## grid 1
2937          [2:------------------------------]|*6
2938          [3:------------------------------]|
2939        ## grid 2
2940          {10:This is a }                    |
2941          {10:valid English }                |
2942          {105:sentence composed by·}{13:·········}|
2943          {10:in his cave. }                 |
2944          {10:^ }                             |
2945          {1:~                             }|
2946        ## grid 3
2947                                        |
2948        ]])
2949      else
2950        screen:expect([[
2951          {10:This is a }                    |
2952          {10:valid English }                |
2953          {105:sentence composed by·}{13:·········}|
2954          {10:in his cave. }                 |
2955          {10:^ }                             |
2956          {1:~                             }|
2957                                        |
2958        ]])
2959      end
2960
2961      command('set list')
2962      screen:expect_unchanged() -- No "eol" set for &listchars yet.
2963
2964      command("set listchars+=eol:& | let @/ = '.'")
2965      if multigrid then
2966        screen:expect([[
2967        ## grid 1
2968          [2:------------------------------]|*6
2969          [3:------------------------------]|
2970        ## grid 2
2971          {10:This is a}{1:&}                    |
2972          {10:valid English}{1:&}                |
2973          {105:sentence composed by}{104:&}{13:·········}|
2974          {10:in his cave.}{1:&}                 |
2975          {1:^&}                             |
2976          {1:~                             }|
2977        ## grid 3
2978                                        |
2979        ]])
2980      else
2981        screen:expect([[
2982          {10:This is a}{1:&}                    |
2983          {10:valid English}{1:&}                |
2984          {105:sentence composed by}{104:&}{13:·········}|
2985          {10:in his cave.}{1:&}                 |
2986          {1:^&}                             |
2987          {1:~                             }|
2988                                        |
2989        ]])
2990      end
2991
2992      command("let @/ = '$'")
2993      if multigrid then
2994        screen:expect([[
2995        ## grid 1
2996          [2:------------------------------]|*6
2997          [3:------------------------------]|
2998        ## grid 2
2999          This is a{109:&}                    |
3000          valid English{109:&}                |
3001          {13:sentence composed by}{109:&}{13:·········}|
3002          in his cave.{109:&}                 |
3003          {109:^&}                             |
3004          {1:~                             }|
3005        ## grid 3
3006                                        |
3007        ]])
3008      else
3009        screen:expect([[
3010          This is a{109:&}                    |
3011          valid English{109:&}                |
3012          {13:sentence composed by}{109:&}{13:·········}|
3013          in his cave.{109:&}                 |
3014          {109:^&}                             |
3015          {1:~                             }|
3016                                        |
3017        ]])
3018      end
3019
3020      command("let @/ = '.\\?'")
3021      if multigrid then
3022        screen:expect([[
3023        ## grid 1
3024          [2:------------------------------]|*6
3025          [3:------------------------------]|
3026        ## grid 2
3027          {10:This is a}{109:&}                    |
3028          {10:valid English}{109:&}                |
3029          {105:sentence composed by}{109:&}{13:·········}|
3030          {10:in his cave.}{109:&}                 |
3031          {109:^&}                             |
3032          {1:~                             }|
3033        ## grid 3
3034                                        |
3035        ]])
3036      else
3037        screen:expect([[
3038          {10:This is a}{109:&}                    |
3039          {10:valid English}{109:&}                |
3040          {105:sentence composed by}{109:&}{13:·········}|
3041          {10:in his cave.}{109:&}                 |
3042          {109:^&}                             |
3043          {1:~                             }|
3044                                        |
3045        ]])
3046      end
3047    end)
3048  end
3049
3050  describe('with ext_multigrid', function()
3051    with_ext_multigrid(true)
3052  end)
3053
3054  describe('without ext_multigrid', function()
3055    with_ext_multigrid(false)
3056  end)
3057
3058  it('does not hang drawing diff filler above a folded line', function()
3059    Screen.new(80, 24)
3060    exec([[
3061      call setline(1, ['fold', 'body'])
3062      vnew
3063      call setline(1, ['inserted', 'fold', 'body'])
3064
3065      windo diffthis
3066      wincmd l
3067      setlocal foldmethod=manual
3068      1,2fold
3069      normal! zM
3070
3071      wincmd h
3072      normal! 1Gzt
3073      redraw
3074
3075      let g:diff_filler_fold_done = 1
3076    ]])
3077    eq(1, api.nvim_get_var('diff_filler_fold_done'))
3078    assert_alive()
3079  end)
3080
3081  it("do not interfere with corrected cursor position for 'scrolloff'", function()
3082    local screen = Screen.new(40, 7)
3083    exec([[
3084      call setline(1, range(10))
3085      6,7fold
3086      set scrolloff=1
3087      norm L
3088    ]])
3089    screen:expect([[
3090      0                                       |
3091      1                                       |
3092      2                                       |
3093      3                                       |
3094      ^4                                       |
3095      {13:+--  2 lines: 5·························}|
3096                                              |
3097    ]])
3098  end)
3099end)