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