neovim

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

sign_spec.lua (34261B)


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