robin/laufey

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

robinmerge: 1dc9728daa1d8a2702

master
36.7 KiB891 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, command = n.clear, n.feed, n.command
7local eq = t.eq
8local insert = n.insert
9local poke_eventloop = n.poke_eventloop
10local exec = n.exec
11
12describe('Screen', function()
13  local screen
14
15  before_each(function()
16    clear()
17    screen = Screen.new(nil, 10)
18    screen:set_default_attr_ids({
19      [0] = { bold = true, foreground = Screen.colors.Blue },
20      [1] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray },
21      [2] = { bold = true, reverse = true },
22      [3] = { reverse = true },
23      [4] = { bold = true },
24      [5] = { background = Screen.colors.Yellow },
25      [6] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey },
26    })
27  end)
28
29  describe('match and conceal', function()
30    before_each(function()
31      command('let &conceallevel=1')
32    end)
33
34    describe('multiple', function()
35      before_each(function()
36        insert([[
37          &&
38          &&
39          &&
40          &&
41          &&
42          &&
43          ]])
44        command("syn match dAmpersand '[&][&]' conceal cchar=∧")
45      end)
46
47      it('double characters.', function()
48        screen:expect([[
49            {1:∧}                                                    |*6
50            ^                                                     |
51            {0:~                                                    }|*2
52                                                                 |
53          ]])
54      end)
55
56      it('double characters and move the cursor one line up.', function()
57        feed('k')
58        screen:expect([[
59          {1:∧}                                                    |*5
60          ^&&                                                   |
61                                                               |
62          {0:~                                                    }|*2
63                                                               |
64        ]])
65      end)
66
67      it('double characters and move the cursor to the beginning of the file.', function()
68        feed('gg')
69        screen:expect([[
70          ^&&                                                   |
71          {1:∧}                                                    |*5
72                                                               |
73          {0:~                                                    }|*2
74                                                               |
75        ]])
76      end)
77
78      it('double characters and move the cursor to the second line in the file.', function()
79        feed('ggj')
80        screen:expect([[
81          {1:∧}                                                    |
82          ^&&                                                   |
83          {1:∧}                                                    |*4
84                                                               |
85          {0:~                                                    }|*2
86                                                               |
87        ]])
88      end)
89
90      it(
91        'double characters and then move the cursor to the beginning of the file and back to the end of the file.',
92        function()
93          feed('ggG')
94          screen:expect([[
95          {1:∧}                                                    |*6
96          ^                                                     |
97          {0:~                                                    }|*2
98                                                               |
99        ]])
100        end
101      )
102    end) -- multiple
103
104    it('keyword instances in initially in the document.', function()
105      feed('2ilambda<cr><ESC>')
106      command('let &conceallevel=1')
107      command('syn keyword kLambda lambda conceal cchar=λ')
108      screen:expect([[
109        {1:λ}                                                    |*2
110        ^                                                     |
111        {0:~                                                    }|*6
112                                                             |
113      ]])
114    end) -- Keyword
115
116    describe('regions in the document', function()
117      before_each(function()
118        feed('2')
119        insert('<r> a region of text </r>\n')
120        command('let &conceallevel=1')
121      end)
122
123      it('initially and conceal it.', function()
124        command("syn region rText start='<r>' end='</r>' conceal cchar=R")
125        screen:expect([[
126          {1:R}                                                    |*2
127          ^                                                     |
128          {0:~                                                    }|*6
129                                                               |
130        ]])
131      end)
132
133      it('initially and conceal its start tag and end tag.', function()
134        -- concealends has a known bug (todo.txt) where the first match won't
135        -- be replaced with cchar.
136        command("syn region rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
137        screen:expect([[
138          {1: } a region of text {1:-}                                 |*2
139          ^                                                     |
140          {0:~                                                    }|*6
141                                                               |
142        ]])
143      end)
144
145      it("that are nested and conceal the nested region's start and end tags.", function()
146        command(
147          "syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-"
148        )
149        insert('<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n')
150        screen:expect([[
151          {1: } a region of text {1:-}                                 |*2
152          {1: } A region with {1: } a nested {1: } nested region.{1:-}         |
153           {1:-} {1:-}                                                 |
154          ^                                                     |
155          {0:~                                                    }|*4
156                                                               |
157        ]])
158      end)
159    end) -- regions in the document
160
161    describe('a region of text', function()
162      before_each(function()
163        command('syntax conceal on')
164        feed('2')
165        insert('<r> a region of text </r>\n')
166        command("syn region rText start='<r>' end='</r>' cchar=-")
167      end)
168
169      it('and turn on implicit concealing', function()
170        screen:expect([[
171          {1:-}                                                    |*2
172          ^                                                     |
173          {0:~                                                    }|*6
174                                                               |
175        ]])
176      end)
177
178      it('and then turn on, then off, and then back on implicit concealing.', function()
179        command('syntax conceal off')
180        feed('2')
181        insert('<i> italian text </i>\n')
182        command("syn region iText start='<i>' end='</i>' cchar=*")
183        screen:expect([[
184          {1:-}                                                    |*2
185          <i> italian text </i>                                |*2
186          ^                                                     |
187          {0:~                                                    }|*4
188                                                               |
189        ]])
190        command('syntax conceal on')
191        command("syn region iText start='<i>' end='</i>' cchar=*")
192        screen:expect([[
193          {1:-}                                                    |*2
194          {1:*}                                                    |*2
195          ^                                                     |
196          {0:~                                                    }|*4
197                                                               |
198        ]])
199      end)
200    end) -- a region of text (implicit concealing)
201
202    it('cursor position when entering Insert mode with cocu=ni #13916', function()
203      insert([[foobarfoobarfoobar]])
204      -- move to end of line
205      feed('$')
206      command('set concealcursor=ni')
207      command('syn match Foo /foobar/ conceal cchar=&')
208      screen:expect([[
209        {1:&&&}^                                                  |
210        {0:~                                                    }|*8
211                                                             |
212      ]])
213      feed('i')
214      -- cursor should stay in place, not jump to column 16
215      screen:expect([[
216        {1:&&&}^                                                  |
217        {0:~                                                    }|*8
218        {4:-- INSERT --}                                         |
219      ]])
220    end)
221
222    it('cursor position when scrolling in Normal mode with cocu=n #31271', function()
223      insert(('foo\n'):rep(9) .. 'foofoobarfoofoo' .. ('\nfoo'):rep(9))
224      command('set concealcursor=n')
225      command('syn match Foo /bar/ conceal cchar=&')
226      feed('gg5<C-E>10gg$')
227      screen:expect([[
228        foo                                                  |*4
229        foofoo{1:&}foofo^o                                        |
230        foo                                                  |*4
231                                                             |
232      ]])
233      feed('zz')
234      screen:expect_unchanged()
235      feed('zt')
236      screen:expect([[
237        foofoo{1:&}foofo^o                                        |
238        foo                                                  |*8
239                                                             |
240      ]])
241      feed('zt')
242      screen:expect_unchanged()
243      feed('zb')
244      screen:expect([[
245        foo                                                  |*8
246        foofoo{1:&}foofo^o                                        |
247                                                             |
248      ]])
249      feed('zb')
250      screen:expect_unchanged()
251    end)
252  end) -- match and conceal
253
254  describe('let the conceal level be', function()
255    before_each(function()
256      insert('// No Conceal\n')
257      insert('"Conceal without a cchar"\n')
258      insert('+ With cchar\n\n')
259      command("syn match noConceal '^//.*$'")
260      command('syn match concealNoCchar \'".\\{-}"$\' conceal')
261      command("syn match concealWCchar '^+.\\{-}$' conceal cchar=C")
262    end)
263
264    it('0. No concealing.', function()
265      command('let &conceallevel=0')
266      screen:expect([[
267        // No Conceal                                        |
268        "Conceal without a cchar"                            |
269        + With cchar                                         |
270                                                             |
271        ^                                                     |
272        {0:~                                                    }|*4
273                                                             |
274      ]])
275    end)
276
277    it('1. Conceal using cchar or reference listchars.', function()
278      command('let &conceallevel=1')
279      screen:expect([[
280        // No Conceal                                        |
281        {1: }                                                    |
282        {1:C}                                                    |
283                                                             |
284        ^                                                     |
285        {0:~                                                    }|*4
286                                                             |
287      ]])
288    end)
289
290    it('2. Hidden unless cchar is set.', function()
291      command('let &conceallevel=2')
292      screen:expect([[
293        // No Conceal                                        |
294                                                             |
295        {1:C}                                                    |
296                                                             |
297        ^                                                     |
298        {0:~                                                    }|*4
299                                                             |
300      ]])
301    end)
302
303    it('3. Hide all concealed text.', function()
304      command('let &conceallevel=3')
305      screen:expect([[
306        // No Conceal                                        |
307                                                             |*3
308        ^                                                     |
309        {0:~                                                    }|*4
310                                                             |
311      ]])
312    end)
313  end) -- conceallevel
314
315  describe('cursor movement', function()
316    before_each(function()
317      command('syn keyword concealy barf conceal cchar=b')
318      command('set cole=2')
319      feed('5Ofoo barf bar barf eggs<esc>')
320      screen:expect([[
321        foo {1:b} bar {1:b} eggs                                     |*4
322        foo barf bar barf egg^s                               |
323                                                             |
324        {0:~                                                    }|*3
325                                                             |
326      ]])
327    end)
328
329    it('between windows', function()
330      feed('k')
331      command('split')
332      screen:expect([[
333        foo {1:b} bar {1:b} eggs                                     |
334        foo barf bar barf egg^s                               |
335        foo {1:b} bar {1:b} eggs                                     |
336                                                             |
337        {2:[No Name] [+]                                        }|
338        foo {1:b} bar {1:b} eggs                                     |*3
339        {3:[No Name] [+]                                        }|
340                                                             |
341      ]])
342      feed('<c-w>w')
343
344      screen:expect([[
345        foo {1:b} bar {1:b} eggs                                     |*3
346                                                             |
347        {3:[No Name] [+]                                        }|
348        foo {1:b} bar {1:b} eggs                                     |
349        foo barf bar barf egg^s                               |
350        foo {1:b} bar {1:b} eggs                                     |
351        {2:[No Name] [+]                                        }|
352                                                             |
353      ]])
354    end)
355
356    it('in insert mode', function()
357      feed('i')
358      screen:expect([[
359        foo {1:b} bar {1:b} eggs                                     |*4
360        foo barf bar barf egg^s                               |
361                                                             |
362        {0:~                                                    }|*3
363        {4:-- INSERT --}                                         |
364      ]])
365
366      feed('<up>')
367      screen:expect([[
368        foo {1:b} bar {1:b} eggs                                     |*3
369        foo barf bar barf egg^s                               |
370        foo {1:b} bar {1:b} eggs                                     |
371                                                             |
372        {0:~                                                    }|*3
373        {4:-- INSERT --}                                         |
374      ]])
375    end)
376
377    it('between modes cocu=iv', function()
378      command('set cocu=iv')
379      feed('gg')
380      screen:expect([[
381        ^foo barf bar barf eggs                               |
382        foo {1:b} bar {1:b} eggs                                     |*4
383                                                             |
384        {0:~                                                    }|*3
385                                                             |
386      ]])
387
388      feed('i')
389      screen:expect([[
390        ^foo {1:b} bar {1:b} eggs                                     |
391        foo {1:b} bar {1:b} eggs                                     |*4
392                                                             |
393        {0:~                                                    }|*3
394        {4:-- INSERT --}                                         |
395      ]])
396
397      feed('<esc>')
398      screen:expect([[
399        ^foo barf bar barf eggs                               |
400        foo {1:b} bar {1:b} eggs                                     |*4
401                                                             |
402        {0:~                                                    }|*3
403                                                             |
404      ]])
405
406      feed('v')
407      screen:expect([[
408        {6:^f}oo {1:b} bar {1:b} eggs                                     |
409        foo {1:b} bar {1:b} eggs                                     |*4
410                                                             |
411        {0:~                                                    }|*3
412        {4:-- VISUAL --}                                         |
413      ]])
414
415      feed('<esc>')
416      screen:expect([[
417        ^foo barf bar barf eggs                               |
418        foo {1:b} bar {1:b} eggs                                     |*4
419                                                             |
420        {0:~                                                    }|*3
421                                                             |
422      ]])
423    end)
424
425    it('between modes cocu=n', function()
426      command('set cocu=n')
427      feed('gg')
428      screen:expect([[
429        ^foo {1:b} bar {1:b} eggs                                     |
430        foo {1:b} bar {1:b} eggs                                     |*4
431                                                             |
432        {0:~                                                    }|*3
433                                                             |
434      ]])
435
436      feed('i')
437      screen:expect([[
438        ^foo barf bar barf eggs                               |
439        foo {1:b} bar {1:b} eggs                                     |*4
440                                                             |
441        {0:~                                                    }|*3
442        {4:-- INSERT --}                                         |
443      ]])
444
445      feed('<esc>')
446      screen:expect([[
447        ^foo {1:b} bar {1:b} eggs                                     |
448        foo {1:b} bar {1:b} eggs                                     |*4
449                                                             |
450        {0:~                                                    }|*3
451                                                             |
452      ]])
453
454      feed('v')
455      screen:expect([[
456        {6:^f}oo barf bar barf eggs                               |
457        foo {1:b} bar {1:b} eggs                                     |*4
458                                                             |
459        {0:~                                                    }|*3
460        {4:-- VISUAL --}                                         |
461      ]])
462
463      feed('<esc>')
464      screen:expect([[
465        ^foo {1:b} bar {1:b} eggs                                     |
466        foo {1:b} bar {1:b} eggs                                     |*4
467                                                             |
468        {0:~                                                    }|*3
469                                                             |
470      ]])
471
472      feed('r')
473      screen:expect_unchanged()
474
475      feed('m')
476      screen:expect([[
477        ^moo {1:b} bar {1:b} eggs                                     |
478        foo {1:b} bar {1:b} eggs                                     |*4
479                                                             |
480        {0:~                                                    }|*3
481                                                             |
482      ]])
483    end)
484
485    it('and open line', function()
486      feed('o')
487      screen:expect([[
488        foo {1:b} bar {1:b} eggs                                     |*5
489        ^                                                     |
490                                                             |
491        {0:~                                                    }|*2
492        {4:-- INSERT --}                                         |
493      ]])
494    end)
495
496    it('and open line cocu=i', function()
497      command('set cocu=i')
498      feed('o')
499      screen:expect([[
500        foo {1:b} bar {1:b} eggs                                     |*5
501        ^                                                     |
502                                                             |
503        {0:~                                                    }|*2
504        {4:-- INSERT --}                                         |
505      ]])
506    end)
507
508    describe('with incsearch', function()
509      before_each(function()
510        command('set incsearch hlsearch')
511        feed('2GA x<esc>3GA xy<esc>gg')
512        screen:expect([[
513          ^foo barf bar barf eggs                               |
514          foo {1:b} bar {1:b} eggs x                                   |
515          foo {1:b} bar {1:b} eggs xy                                  |
516          foo {1:b} bar {1:b} eggs                                     |*2
517                                                               |
518          {0:~                                                    }|*3
519                                                               |
520        ]])
521      end)
522
523      it('cocu=', function()
524        feed('/')
525        screen:expect([[
526          foo barf bar barf eggs                               |
527          foo {1:b} bar {1:b} eggs x                                   |
528          foo {1:b} bar {1:b} eggs xy                                  |
529          foo {1:b} bar {1:b} eggs                                     |*2
530                                                               |
531          {0:~                                                    }|*3
532          /^                                                    |
533        ]])
534
535        feed('x')
536        screen:expect([[
537          foo {1:b} bar {1:b} eggs                                     |
538          foo barf bar barf eggs {3:x}                             |
539          foo {1:b} bar {1:b} eggs {5:x}y                                  |
540          foo {1:b} bar {1:b} eggs                                     |*2
541                                                               |
542          {0:~                                                    }|*3
543          /x^                                                   |
544        ]])
545
546        feed('y')
547        screen:expect([[
548          foo {1:b} bar {1:b} eggs                                     |
549          foo {1:b} bar {1:b} eggs x                                   |
550          foo barf bar barf eggs {3:xy}                            |
551          foo {1:b} bar {1:b} eggs                                     |*2
552                                                               |
553          {0:~                                                    }|*3
554          /xy^                                                  |
555        ]])
556
557        feed('<c-w>')
558        screen:expect([[
559          foo barf bar barf eggs                               |
560          foo {1:b} bar {1:b} eggs x                                   |
561          foo {1:b} bar {1:b} eggs xy                                  |
562          foo {1:b} bar {1:b} eggs                                     |*2
563                                                               |
564          {0:~                                                    }|*3
565          /^                                                    |
566        ]])
567      end)
568
569      it('cocu=c', function()
570        command('set cocu=c')
571
572        feed('/')
573        -- NB: we don't do this redraw. Probably best to still skip it,
574        -- to avoid annoying distraction from the cmdline
575        screen:expect([[
576          foo barf bar barf eggs                               |
577          foo {1:b} bar {1:b} eggs x                                   |
578          foo {1:b} bar {1:b} eggs xy                                  |
579          foo {1:b} bar {1:b} eggs                                     |*2
580                                                               |
581          {0:~                                                    }|*3
582          /^                                                    |
583        ]])
584
585        feed('x')
586        screen:expect([[
587          foo {1:b} bar {1:b} eggs                                     |
588          foo {1:b} bar {1:b} eggs {3:x}                                   |
589          foo {1:b} bar {1:b} eggs {5:x}y                                  |
590          foo {1:b} bar {1:b} eggs                                     |*2
591                                                               |
592          {0:~                                                    }|*3
593          /x^                                                   |
594        ]])
595
596        feed('y')
597        screen:expect([[
598          foo {1:b} bar {1:b} eggs                                     |
599          foo {1:b} bar {1:b} eggs x                                   |
600          foo {1:b} bar {1:b} eggs {3:xy}                                  |
601          foo {1:b} bar {1:b} eggs                                     |*2
602                                                               |
603          {0:~                                                    }|*3
604          /xy^                                                  |
605        ]])
606
607        feed('<c-w>')
608        screen:expect([[
609          foo {1:b} bar {1:b} eggs                                     |
610          foo {1:b} bar {1:b} eggs x                                   |
611          foo {1:b} bar {1:b} eggs xy                                  |
612          foo {1:b} bar {1:b} eggs                                     |*2
613                                                               |
614          {0:~                                                    }|*3
615          /^                                                    |
616        ]])
617
618        feed('<esc>')
619        screen:expect([[
620          ^foo barf bar barf eggs                               |
621          foo {1:b} bar {1:b} eggs x                                   |
622          foo {1:b} bar {1:b} eggs xy                                  |
623          foo {1:b} bar {1:b} eggs                                     |*2
624                                                               |
625          {0:~                                                    }|*3
626                                                               |
627        ]])
628      end)
629
630      it('cocu=n', function()
631        command('set cocu=n')
632        screen:expect([[
633          ^foo {1:b} bar {1:b} eggs                                     |
634          foo {1:b} bar {1:b} eggs x                                   |
635          foo {1:b} bar {1:b} eggs xy                                  |
636          foo {1:b} bar {1:b} eggs                                     |*2
637                                                               |
638          {0:~                                                    }|*3
639                                                               |
640        ]])
641
642        feed('/')
643        -- NB: we don't do this redraw. Probably best to still skip it,
644        -- to avoid annoying distraction from the cmdline
645        screen:expect([[
646          foo {1:b} bar {1:b} eggs                                     |
647          foo {1:b} bar {1:b} eggs x                                   |
648          foo {1:b} bar {1:b} eggs xy                                  |
649          foo {1:b} bar {1:b} eggs                                     |*2
650                                                               |
651          {0:~                                                    }|*3
652          /^                                                    |
653        ]])
654
655        feed('x')
656        screen:expect([[
657          foo {1:b} bar {1:b} eggs                                     |
658          foo barf bar barf eggs {3:x}                             |
659          foo {1:b} bar {1:b} eggs {5:x}y                                  |
660          foo {1:b} bar {1:b} eggs                                     |*2
661                                                               |
662          {0:~                                                    }|*3
663          /x^                                                   |
664        ]])
665
666        feed('<c-w>')
667        screen:expect([[
668          foo barf bar barf eggs                               |
669          foo {1:b} bar {1:b} eggs x                                   |
670          foo {1:b} bar {1:b} eggs xy                                  |
671          foo {1:b} bar {1:b} eggs                                     |*2
672                                                               |
673          {0:~                                                    }|*3
674          /^                                                    |
675        ]])
676
677        feed('<esc>')
678        screen:expect([[
679          ^foo {1:b} bar {1:b} eggs                                     |
680          foo {1:b} bar {1:b} eggs x                                   |
681          foo {1:b} bar {1:b} eggs xy                                  |
682          foo {1:b} bar {1:b} eggs                                     |*2
683                                                               |
684          {0:~                                                    }|*3
685                                                               |
686        ]])
687      end)
688    end)
689
690    it('redraws properly with concealcursor in visual mode', function()
691      command('set concealcursor=v conceallevel=2')
692
693      feed('10Ofoo barf bar barf eggs<esc>')
694      feed(':3<cr>o    a<Esc>ggV')
695      screen:expect {
696        grid = [[
697        {6:^foo }{1:b}{6: bar }{1:b}{6: eggs}                                     |
698        foo {1:b} bar {1:b} eggs                                     |*2
699            a                                                |
700        foo {1:b} bar {1:b} eggs                                     |*5
701        {4:-- VISUAL LINE --}                                    |
702      ]],
703      }
704      feed(string.rep('j', 15))
705      screen:expect {
706        grid = [[
707        {6:foo }{1:b}{6: bar }{1:b}{6: eggs}                                     |*8
708        {6:^foo }{1:b}{6: bar }{1:b}{6: eggs}                                     |
709        {4:-- VISUAL LINE --}                                    |
710      ]],
711      }
712      feed(string.rep('k', 15))
713      screen:expect {
714        grid = [[
715        {6:^foo }{1:b}{6: bar }{1:b}{6: eggs}                                     |
716        foo {1:b} bar {1:b} eggs                                     |*2
717            a                                                |
718        foo {1:b} bar {1:b} eggs                                     |*5
719        {4:-- VISUAL LINE --}                                    |
720      ]],
721      }
722    end)
723  end)
724
725  it('redraws not too much with conceallevel=1', function()
726    command('set conceallevel=1')
727    command('set redrawdebug+=nodelta')
728
729    insert([[
730    aaa
731    bbb
732    ccc
733    ]])
734    screen:expect {
735      grid = [[
736      aaa                                                  |
737      bbb                                                  |
738      ccc                                                  |
739      ^                                                     |
740      {0:~                                                    }|*5
741                                                           |
742    ]],
743    }
744
745    -- XXX: hack to get notifications, and check only a single line is
746    --      updated.  Could use next_msg() also.
747    local orig_handle_grid_line = screen._handle_grid_line
748    local grid_lines = {}
749    function screen._handle_grid_line(self, grid, row, col, items)
750      table.insert(grid_lines, { row, col, items })
751      orig_handle_grid_line(self, grid, row, col, items)
752    end
753    feed('k')
754    screen:expect {
755      grid = [[
756      aaa                                                  |
757      bbb                                                  |
758      ^ccc                                                  |
759                                                           |
760      {0:~                                                    }|*5
761                                                           |
762    ]],
763    }
764    eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } }, { 3, 0, { { ' ', 0, 53 } } } }, grid_lines)
765  end)
766
767  it('K_EVENT should not cause extra redraws with concealcursor #13196', function()
768    command('set conceallevel=1')
769    command('set concealcursor=nv')
770    command('set redrawdebug+=nodelta')
771
772    insert([[
773    aaa
774    bbb
775    ccc
776    ]])
777    screen:expect {
778      grid = [[
779      aaa                                                  |
780      bbb                                                  |
781      ccc                                                  |
782      ^                                                     |
783      {0:~                                                    }|*5
784                                                           |
785    ]],
786    }
787
788    -- XXX: hack to get notifications, and check only a single line is
789    --      updated.  Could use next_msg() also.
790    local orig_handle_grid_line = screen._handle_grid_line
791    local grid_lines = {}
792    function screen._handle_grid_line(self, grid, row, col, items)
793      table.insert(grid_lines, { row, col, items })
794      orig_handle_grid_line(self, grid, row, col, items)
795    end
796    feed('k')
797    screen:expect {
798      grid = [[
799      aaa                                                  |
800      bbb                                                  |
801      ^ccc                                                  |
802                                                           |
803      {0:~                                                    }|*5
804                                                           |
805    ]],
806    }
807    eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } } }, grid_lines)
808    grid_lines = {}
809    poke_eventloop() -- causes K_EVENT key
810    screen:expect_unchanged()
811    eq({}, grid_lines) -- no redraw was done
812  end)
813
814  describe('concealed line has the correct cursor column', function()
815    -- oldtest: Test_cursor_column_in_concealed_line_after_window_scroll()
816    it('after window scroll', function()
817      insert([[
818        3split
819        let m = matchadd('Conceal', '=')
820        setl conceallevel=2 concealcursor=nc
821        normal gg
822        "==expr==]])
823      feed('gg')
824      command('file Xcolesearch')
825      command('set nomodified')
826
827      command('so')
828      screen:expect {
829        grid = [[
830        ^3split                                               |
831        let m  matchadd('Conceal', '')                       |
832        setl conceallevel2 concealcursornc                   |
833        {2:Xcolesearch                                          }|
834        3split                                               |
835        let m = matchadd('Conceal', '=')                     |
836        setl conceallevel=2 concealcursor=nc                 |
837        normal gg                                            |
838        {3:Xcolesearch                                          }|
839                                                             |
840      ]],
841      }
842
843      -- Jump to something that is beyond the bottom of the window,
844      -- so there's a scroll down.
845      feed('/expr<CR>')
846
847      -- Are the concealed parts of the current line really hidden?
848      -- Is the window's cursor column properly updated for hidden
849      -- parts of the current line?
850      screen:expect {
851        grid = [[
852        setl conceallevel2 concealcursornc                   |
853        normal gg                                            |
854        "{5:^expr}                                                |
855        {2:Xcolesearch                                          }|
856        3split                                               |
857        let m = matchadd('Conceal', '=')                     |
858        setl conceallevel=2 concealcursor=nc                 |
859        normal gg                                            |
860        {3:Xcolesearch                                          }|
861        /expr                                                |
862      ]],
863      }
864    end)
865
866    -- oldtest: Test_cursor_column_in_concealed_line_after_leftcol_change()
867    it('after leftcol change', function()
868      exec([[
869        0put = 'ab' .. repeat('-', &columns) .. 'c'
870        call matchadd('Conceal', '-')
871        set nowrap ss=0 cole=3 cocu=n
872      ]])
873
874      -- Go to the end of the line (3 columns beyond the end of the screen).
875      -- Horizontal scroll would center the cursor in the screen line, but conceal
876      -- makes it go to screen column 1.
877      feed('$')
878
879      -- Are the concealed parts of the current line really hidden?
880      -- Is the window's cursor column properly updated for conceal?
881      screen:expect {
882        grid = [[
883        ^c                                                    |
884                                                             |
885        {0:~                                                    }|*7
886                                                             |
887      ]],
888      }
889    end)
890  end)
891end)