statusline_spec.lua 4.3 KB

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