robin/laufey

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

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

master
5.1 KiB152 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('statusline', function()
13  local screen
14
15  before_each(function()
16    screen = Screen.new(50, 7)
17    screen:add_extra_attr_ids({
18      [100] = {
19        background = Screen.colors.Red,
20        foreground = Screen.colors.Gray100,
21        reverse = true,
22        bold = true,
23      },
24      [101] = { foreground = Screen.colors.Blue, reverse = true, bold = true },
25    })
26  end)
27
28  it('is updated in cmdline mode when using window-local statusline vim-patch:8.2.2737', function()
29    exec([[
30      setlocal statusline=-%{mode()}-
31      split
32      setlocal statusline=+%{mode()}+
33    ]])
34    screen:expect([[
35      ^                                                  |
36      {1:~                                                 }|
37      {3:+n+                                               }|
38                                                        |
39      {1:~                                                 }|
40      {2:-n-                                               }|
41                                                        |
42    ]])
43    feed(':')
44    screen:expect([[
45                                                        |
46      {1:~                                                 }|
47      {3:+c+                                               }|
48                                                        |
49      {1:~                                                 }|
50      {2:-c-                                               }|
51      :^                                                 |
52    ]])
53  end)
54
55  it('truncated item does not cause off-by-one highlight vim-patch:8.2.4929', function()
56    exec([[
57      set laststatus=2
58      hi! link User1 Directory
59      hi! link User2 ErrorMsg
60      set statusline=%.5(%1*ABC%2*DEF%1*GHI%)
61    ]])
62    screen:expect([[
63      ^                                                  |
64      {1:~                                                 }|*4
65      {100:<F}{101:GHI                                             }|
66                                                        |
67    ]])
68  end)
69
70  -- oldtest: Test_statusline_showcmd()
71  it('showcmdloc=statusline works', function()
72    exec([[
73      func MyStatusLine()
74        return '%S'
75      endfunc
76
77      set showcmd
78      set laststatus=2
79      set statusline=%S
80      set showcmdloc=statusline
81      call setline(1, ['a', 'b', 'c'])
82      set foldopen+=jump
83      1,2fold
84      3
85    ]])
86
87    feed('g')
88    screen:expect([[
89      {13:+--  2 lines: a···································}|
90      ^c                                                 |
91      {1:~                                                 }|*3
92      {3:g                                                 }|
93                                                        |
94    ]])
95
96    -- typing "gg" should open the fold
97    feed('g')
98    screen:expect([[
99      ^a                                                 |
100      b                                                 |
101      c                                                 |
102      {1:~                                                 }|*2
103      {3:                                                  }|
104                                                        |
105    ]])
106
107    feed('<C-V>Gl')
108    screen:expect([[
109      {17:a}                                                 |
110      {17:b}                                                 |
111      {17:c}^                                                 |
112      {1:~                                                 }|*2
113      {3:3x2                                               }|
114      {5:-- VISUAL BLOCK --}                                |
115    ]])
116
117    feed('<Esc>1234')
118    screen:expect([[
119      a                                                 |
120      b                                                 |
121      ^c                                                 |
122      {1:~                                                 }|*2
123      {3:1234                                              }|
124                                                        |
125    ]])
126
127    feed('<Esc>:set statusline=<CR>')
128    feed(':<CR>')
129    feed('1234')
130    screen:expect([[
131      a                                                 |
132      b                                                 |
133      ^c                                                 |
134      {1:~                                                 }|*2
135      {3:[No Name] [+]                          1234       }|
136      :                                                 |
137    ]])
138  end)
139
140  -- oldtest: Test_statusline_showcmd_nop_map()
141  it('showcmdloc=statusline is redrawn with timeout and <Nop> mapping', function()
142    exec([[
143      set timeoutlen=500 showcmd showcmdloc=statusline laststatus=2
144      nnoremap <space> <nop>
145      nnoremap <space><space> <nop>
146    ]])
147    feed(' ')
148    screen:expect({ any = '<20>', timeout = 400 })
149    vim.uv.sleep(500)
150    screen:expect({ none = '<20>', timeout = 400 })
151  end)
152end)