neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

syntax_conceal_spec.lua (37468B)


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