robin/laufey

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

zeertzjqMerge pull request #40977 from zeertzjq/vim-9.2.0806e5aac37eb3

master
3.2 KiB100 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 exec = n.exec
8local feed = n.feed
9
10before_each(clear)
11
12describe('tabline', function()
13  local screen
14
15  before_each(function()
16    screen = Screen.new(50, 7)
17  end)
18
19  -- oldtest: Test_tabline_showcmd()
20  it('showcmdloc=tabline works', function()
21    exec([[
22      func MyTabLine()
23        return '%S'
24      endfunc
25
26      set showcmd
27      set showtabline=2
28      set tabline=%!MyTabLine()
29      set showcmdloc=tabline
30      call setline(1, ['a', 'b', 'c'])
31      set foldopen+=jump
32      1,2fold
33      3
34    ]])
35
36    feed('g')
37    screen:expect([[
38      {2:g                                                 }|
39      {13:+--  2 lines: a···································}|
40      ^c                                                 |
41      {1:~                                                 }|*3
42                                                        |
43    ]])
44
45    -- typing "gg" should open the fold
46    feed('g')
47    screen:expect([[
48      {2:                                                  }|
49      ^a                                                 |
50      b                                                 |
51      c                                                 |
52      {1:~                                                 }|*2
53                                                        |
54    ]])
55
56    feed('<C-V>Gl')
57    screen:expect([[
58      {2:3x2                                               }|
59      {17:a}                                                 |
60      {17:b}                                                 |
61      {17:c}^                                                 |
62      {1:~                                                 }|*2
63      {5:-- VISUAL BLOCK --}                                |
64    ]])
65
66    feed('<Esc>1234')
67    screen:expect([[
68      {2:1234                                              }|
69      a                                                 |
70      b                                                 |
71      ^c                                                 |
72      {1:~                                                 }|*2
73                                                        |
74    ]])
75
76    feed('<Esc>:set tabline=<CR>')
77    feed(':<CR>')
78    feed('1234')
79    screen:expect([[
80      {5: + [No Name] }{2:                           }{24:1234}{2:      }|
81      a                                                 |
82      b                                                 |
83      ^c                                                 |
84      {1:~                                                 }|*2
85      :                                                 |
86    ]])
87  end)
88
89  -- oldtest: Test_tabline_showcmd_redraw_tabline()
90  it('clears showcmd rendered by tabline redraw', function()
91    exec([[
92      set showcmd showcmdloc=tabline showtabline=2 tabline=%S timeoutlen=0
93      nnoremap g :redraw<CR>
94      nnoremap gc <Nop>
95    ]])
96    feed('g')
97    screen:expect({ any = ':redraw', none = '{2::' })
98    t.eq('', n.api.nvim_eval_statusline('%S', {}).str)
99  end)
100end)