neovim

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

match_spec.lua (4122B)


      1 local n = require('test.functional.testnvim')()
      2 local Screen = require('test.functional.ui.screen')
      3 
      4 local clear = n.clear
      5 local exec = n.exec
      6 local feed = n.feed
      7 
      8 before_each(clear)
      9 
     10 describe('matchaddpos()', function()
     11  -- oldtest: Test_matchaddpos_dump()
     12  it('can add more than 8 match positions vim-patch:9.0.0620', function()
     13    local screen = Screen.new(60, 14)
     14    exec([[
     15      call setline(1, ['1234567890123']->repeat(14))
     16      call matchaddpos('Search', range(1, 12)->map({i, v -> [v, v]}))
     17    ]])
     18    screen:expect([[
     19      {10:^1}234567890123                                               |
     20      1{10:2}34567890123                                               |
     21      12{10:3}4567890123                                               |
     22      123{10:4}567890123                                               |
     23      1234{10:5}67890123                                               |
     24      12345{10:6}7890123                                               |
     25      123456{10:7}890123                                               |
     26      1234567{10:8}90123                                               |
     27      12345678{10:9}0123                                               |
     28      123456789{10:0}123                                               |
     29      1234567890{10:1}23                                               |
     30      12345678901{10:2}3                                               |
     31      1234567890123                                               |
     32                                                                  |
     33    ]])
     34  end)
     35 end)
     36 
     37 describe('match highlighting', function()
     38  -- oldtest: Test_match_in_linebreak()
     39  it('does not continue in linebreak vim-patch:8.2.3698', function()
     40    local screen = Screen.new(75, 10)
     41    exec([=[
     42      set breakindent linebreak breakat+=]
     43      call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1)
     44      call matchaddpos('ErrorMsg', [[1, 51]])
     45    ]=])
     46    screen:expect([[
     47      ^xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx{9:]}                        |
     48      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx     |
     49      {1:~                                                                          }|*7
     50                                                                                 |
     51    ]])
     52  end)
     53 
     54  it('is shown with incsearch vim-patch:8.2.3940', function()
     55    local screen = Screen.new(75, 6)
     56    exec([[
     57      set incsearch
     58      call setline(1, range(20))
     59      call matchaddpos('ErrorMsg', [3])
     60    ]])
     61    screen:expect([[
     62      ^0                                                                          |
     63      1                                                                          |
     64      {9:2}                                                                          |
     65      3                                                                          |
     66      4                                                                          |
     67                                                                                 |
     68    ]])
     69    feed(':s/0')
     70    screen:expect([[
     71      {10:0}                                                                          |
     72      1                                                                          |
     73      {9:2}                                                                          |
     74      3                                                                          |
     75      4                                                                          |
     76      :s/0^                                                                       |
     77    ]])
     78  end)
     79 
     80  it('on a Tab vim-patch:8.2.4062', function()
     81    local screen = Screen.new(75, 10)
     82    exec([[
     83      set linebreak
     84      call setline(1, "\tix")
     85      call matchadd('ErrorMsg', '\t')
     86    ]])
     87    screen:expect([[
     88      {9:       ^ }ix                                                                 |
     89      {1:~                                                                          }|*8
     90                                                                                 |
     91    ]])
     92  end)
     93 end)