highlight_spec.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local Screen = require('test.functional.ui.screen')
  4. local clear, feed = n.clear, n.feed
  5. local expect = n.expect
  6. local eq = t.eq
  7. local poke_eventloop = n.poke_eventloop
  8. local exc_exec = n.exc_exec
  9. local feed_command = n.feed_command
  10. local exec = n.exec
  11. before_each(clear)
  12. describe(':highlight', function()
  13. it('is working', function()
  14. local screen = Screen.new(35, 10)
  15. -- Basic test if ":highlight" doesn't crash
  16. feed_command('set more')
  17. feed(':highlight<CR>')
  18. -- FIXME(tarruda): We need to be sure the prompt is displayed before
  19. -- continuing, or risk a race condition where some of the following input
  20. -- is discarded resulting in test failure
  21. screen:expect([[
  22. :highlight |
  23. SpecialKey {18:xxx} {18:ctermfg=}4 |
  24. {18:guifg=}Blue |
  25. EndOfBuffer {1:xxx} {18:links to} NonText|
  26. |
  27. TermCursor {2:xxx} {18:cterm=}reverse |
  28. {18:gui=}reverse |
  29. NonText {1:xxx} {18:ctermfg=}12 |
  30. {18:gui=}bold |
  31. {6:-- More --}^ |
  32. ]])
  33. feed('q')
  34. poke_eventloop() -- wait until we're back to normal
  35. feed_command('hi Search')
  36. feed_command('hi Normal')
  37. -- Test setting colors.
  38. -- Test clearing one color and all doesn't generate error or warning
  39. feed_command(
  40. 'hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan'
  41. )
  42. feed_command('hi Group2 cterm=NONE')
  43. feed_command('hi Group3 cterm=bold')
  44. feed_command('redir! @a')
  45. feed_command('hi NewGroup')
  46. feed_command('hi Group2')
  47. feed_command('hi Group3')
  48. feed_command('hi clear NewGroup')
  49. feed_command('hi NewGroup')
  50. feed_command('hi Group2')
  51. feed_command('hi Group2 NONE')
  52. feed_command('hi Group2')
  53. feed_command('hi clear')
  54. feed_command('hi Group3')
  55. feed('<cr>')
  56. eq("Vim(highlight):E475: Invalid argument: cterm='asdf", exc_exec([[hi Crash cterm='asdf]]))
  57. feed_command('redir END')
  58. -- Filter ctermfg and ctermbg, the numbers depend on the terminal
  59. feed_command('0put a')
  60. feed_command([[%s/ctermfg=\d*/ctermfg=2/]])
  61. feed_command([[%s/ctermbg=\d*/ctermbg=3/]])
  62. -- Fix the fileformat
  63. feed_command('set ff&')
  64. feed_command('$d')
  65. -- Assert buffer contents.
  66. expect([[
  67. NewGroup xxx cterm=italic
  68. ctermfg=2
  69. ctermbg=3
  70. guifg=#00ff00
  71. guibg=Cyan
  72. Group2 xxx cleared
  73. Group3 xxx cterm=bold
  74. NewGroup xxx cleared
  75. Group2 xxx cleared
  76. Group2 xxx cleared
  77. Group3 xxx cleared]])
  78. end)
  79. end)
  80. describe('Visual selection highlight', function()
  81. -- oldtest: Test_visual_sbr()
  82. it("when 'showbreak' is set", function()
  83. local screen = Screen.new(60, 6)
  84. exec([[
  85. set showbreak=>
  86. call setline(1, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.')
  87. exe "normal! z1\<CR>"
  88. ]])
  89. feed('v$')
  90. screen:expect([[
  91. {1:>}{17:n, no sea takimata sanctus est Lorem ipsum dolor sit amet.}^ |
  92. |*4
  93. {5:-- VISUAL --} |
  94. ]])
  95. end)
  96. end)