neovim

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

breakindent_spec.lua (5120B)


      1 local n = require('test.functional.testnvim')()
      2 local Screen = require('test.functional.ui.screen')
      3 
      4 local clear = n.clear
      5 local command = n.command
      6 local exec = n.exec
      7 local feed = n.feed
      8 
      9 before_each(clear)
     10 
     11 describe('breakindent', function()
     12  -- oldtest: Test_cursor_position_with_showbreak()
     13  it('cursor shown at correct position with showbreak', function()
     14    local screen = Screen.new(75, 6)
     15    exec([[
     16      set listchars=eol:$
     17      let &signcolumn = 'yes'
     18      let &showbreak = '++'
     19      let &breakindentopt = 'shift:2'
     20      let leftcol = win_getid()->getwininfo()->get(0, {})->get('textoff')
     21      eval repeat('x', &columns - leftcol - 1)->setline(1)
     22      eval 'second line'->setline(2)
     23    ]])
     24 
     25    feed('AX')
     26    screen:expect([[
     27      {7:  }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX|
     28      {7:  }^second line                                                              |
     29      {1:~                                                                          }|*3
     30      {5:-- INSERT --}                                                               |
     31    ]])
     32    -- No line wraps, so changing 'showbreak' should lead to the same screen.
     33    command('setlocal showbreak=+')
     34    screen:expect_unchanged()
     35    -- No line wraps, so setting 'breakindent' should lead to the same screen.
     36    command('setlocal breakindent')
     37    screen:expect_unchanged()
     38    -- The first line now wraps because of "eol" in 'listchars'.
     39    command('setlocal list')
     40    screen:expect([[
     41      {7:  }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX|
     42      {7:  }  {1:+^$}                                                                     |
     43      {7:  }second line{1:$}                                                             |
     44      {1:~                                                                          }|*2
     45      {5:-- INSERT --}                                                               |
     46    ]])
     47    command('setlocal nobreakindent')
     48    screen:expect([[
     49      {7:  }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX|
     50      {7:  }{1:+^$}                                                                       |
     51      {7:  }second line{1:$}                                                             |
     52      {1:~                                                                          }|*2
     53      {5:-- INSERT --}                                                               |
     54    ]])
     55  end)
     56 
     57  -- oldtest: Test_visual_starts_before_skipcol()
     58  it('Visual selection that starts before skipcol shows correctly', function()
     59    local screen = Screen.new(75, 6)
     60    exec([[
     61      1new
     62      setlocal breakindent
     63      call setline(1, "\t" .. join(range(100)))
     64    ]])
     65 
     66    feed('v$')
     67    screen:expect([[
     68      {1:<<<}     {17: 93 94 95 96 97 98 99}^                                              |
     69      {3:[No Name] [+]                                                              }|
     70                                                                                 |
     71      {1:~                                                                          }|
     72      {2:[No Name]                                                                  }|
     73      {5:-- VISUAL --}                                                               |
     74    ]])
     75    command('setlocal showbreak=+++')
     76    screen:expect([[
     77              {1:+++}{17: 90 91 92 93 94 95 96 97 98 99}^                                  |
     78      {3:[No Name] [+]                                                              }|
     79                                                                                 |
     80      {1:~                                                                          }|
     81      {2:[No Name]                                                                  }|
     82      {5:-- VISUAL --}                                                               |
     83    ]])
     84    command('setlocal breakindentopt+=sbr')
     85    screen:expect([[
     86      {1:+++}     {17: 93 94 95 96 97 98 99}^                                              |
     87      {3:[No Name] [+]                                                              }|
     88                                                                                 |
     89      {1:~                                                                          }|
     90      {2:[No Name]                                                                  }|
     91      {5:-- VISUAL --}                                                               |
     92    ]])
     93    command('setlocal nobreakindent')
     94    screen:expect([[
     95      {1:+++}{17: 98 99}^                                                                  |
     96      {3:[No Name] [+]                                                              }|
     97                                                                                 |
     98      {1:~                                                                          }|
     99      {2:[No Name]                                                                  }|
    100      {5:-- VISUAL --}                                                               |
    101    ]])
    102  end)
    103 end)