aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/statusline_spec.lua
blob: 0bc77fe67e216f45946704ed3ef9402fedf16a75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')

local clear = n.clear
local exec = n.exec
local feed = n.feed

before_each(clear)

describe('statusline', function()
  local screen

  before_each(function()
    screen = Screen.new(50, 7)
  end)

  it('is updated in cmdline mode when using window-local statusline vim-patch:8.2.2737', function()
    exec([[
      setlocal statusline=-%{mode()}-
      split
      setlocal statusline=+%{mode()}+
    ]])
    screen:expect([[
      ^                                                  |
      {1:~                                                 }|
      {3:+n+                                               }|
                                                        |
      {1:~                                                 }|
      {2:-n-                                               }|
                                                        |
    ]])
    feed(':')
    screen:expect([[
                                                        |
      {1:~                                                 }|
      {3:+c+                                               }|
                                                        |
      {1:~                                                 }|
      {2:-c-                                               }|
      :^                                                 |
    ]])
  end)

  it('truncated item does not cause off-by-one highlight vim-patch:8.2.4929', function()
    exec([[
      set laststatus=2
      hi! link User1 Directory
      hi! link User2 ErrorMsg
      set statusline=%.5(%1*ABC%2*DEF%1*GHI%)
    ]])
    screen:expect([[
      ^                                                  |
      {1:~                                                 }|*4
      {9:<F}{18:GHI                                             }|
                                                        |
    ]])
  end)

  -- oldtest: Test_statusline_showcmd()
  it('showcmdloc=statusline works', function()
    exec([[
      func MyStatusLine()
        return '%S'
      endfunc

      set showcmd
      set laststatus=2
      set statusline=%S
      set showcmdloc=statusline
      call setline(1, ['a', 'b', 'c'])
      set foldopen+=jump
      1,2fold
      3
    ]])

    feed('g')
    screen:expect([[
      {13:+--  2 lines: a···································}|
      ^c                                                 |
      {1:~                                                 }|*3
      {3:g                                                 }|
                                                        |
    ]])

    -- typing "gg" should open the fold
    feed('g')
    screen:expect([[
      ^a                                                 |
      b                                                 |
      c                                                 |
      {1:~                                                 }|*2
      {3:                                                  }|
                                                        |
    ]])

    feed('<C-V>Gl')
    screen:expect([[
      {17:a}                                                 |
      {17:b}                                                 |
      {17:c}^                                                 |
      {1:~                                                 }|*2
      {3:3x2                                               }|
      {5:-- VISUAL BLOCK --}                                |
    ]])

    feed('<Esc>1234')
    screen:expect([[
      a                                                 |
      b                                                 |
      ^c                                                 |
      {1:~                                                 }|*2
      {3:1234                                              }|
                                                        |
    ]])

    feed('<Esc>:set statusline=<CR>')
    feed(':<CR>')
    feed('1234')
    screen:expect([[
      a                                                 |
      b                                                 |
      ^c                                                 |
      {1:~                                                 }|*2
      {3:[No Name] [+]                          1234       }|
      :                                                 |
    ]])
  end)
end)