robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

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