sign_spec.lua 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, feed, command = helpers.clear, helpers.feed, helpers.command
  4. local source = helpers.source
  5. describe('Signs', function()
  6. local screen
  7. before_each(function()
  8. clear()
  9. screen = Screen.new()
  10. screen:attach()
  11. screen:set_default_attr_ids( {
  12. [0] = {bold=true, foreground=255},
  13. [1] = {background = Screen.colors.Yellow},
  14. [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey},
  15. [3] = {background = Screen.colors.Gray90},
  16. [4] = {bold = true, reverse = true},
  17. [5] = {reverse = true},
  18. [6] = {foreground = Screen.colors.Brown},
  19. [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
  20. [8] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  21. [9] = {bold = true, foreground = Screen.colors.Magenta},
  22. [10] = {foreground = Screen.colors.Blue1},
  23. [11] = {bold = true, foreground = Screen.colors.SeaGreen4},
  24. } )
  25. end)
  26. after_each(function()
  27. screen:detach()
  28. end)
  29. describe(':sign place', function()
  30. it('shadows previously placed signs', function()
  31. feed('ia<cr>b<cr>c<cr><esc>')
  32. command('sign define piet text=>> texthl=Search')
  33. command('sign define pietx text=>! texthl=Search')
  34. command('sign place 1 line=1 name=piet buffer=1')
  35. command('sign place 2 line=3 name=piet buffer=1')
  36. command('sign place 3 line=1 name=pietx buffer=1')
  37. screen:expect([[
  38. {1:>!}a |
  39. {2: }b |
  40. {1:>>}c |
  41. {2: }^ |
  42. {2: }{0:~ }|
  43. {2: }{0:~ }|
  44. {2: }{0:~ }|
  45. {2: }{0:~ }|
  46. {2: }{0:~ }|
  47. {2: }{0:~ }|
  48. {2: }{0:~ }|
  49. {2: }{0:~ }|
  50. {2: }{0:~ }|
  51. |
  52. ]])
  53. end)
  54. it('can be called right after :split', function()
  55. feed('ia<cr>b<cr>c<cr><esc>gg')
  56. -- This used to cause a crash due to :sign using a special redraw
  57. -- (not updating nvim's specific highlight data structures)
  58. -- without proper redraw first, as split just flags for redraw later.
  59. source([[
  60. set cursorline
  61. sign define piet text=>> texthl=Search
  62. split
  63. sign place 3 line=2 name=piet buffer=1
  64. ]])
  65. screen:expect([[
  66. {2: }{3:^a }|
  67. {1:>>}b |
  68. {2: }c |
  69. {2: } |
  70. {2: }{0:~ }|
  71. {2: }{0:~ }|
  72. {4:[No Name] [+] }|
  73. {2: }{3:a }|
  74. {1:>>}b |
  75. {2: }c |
  76. {2: } |
  77. {2: }{0:~ }|
  78. {5:[No Name] [+] }|
  79. |
  80. ]])
  81. end)
  82. it('can combine text, linehl and numhl', function()
  83. feed('ia<cr>b<cr>c<cr><esc>')
  84. command('set number')
  85. command('sign define piet text=>> texthl=Search')
  86. command('sign define pietx linehl=ErrorMsg')
  87. command('sign define pietxx numhl=Folded')
  88. command('sign place 1 line=1 name=piet buffer=1')
  89. command('sign place 2 line=2 name=pietx buffer=1')
  90. command('sign place 3 line=3 name=pietxx buffer=1')
  91. command('sign place 4 line=4 name=piet buffer=1')
  92. command('sign place 5 line=4 name=pietx buffer=1')
  93. command('sign place 6 line=4 name=pietxx buffer=1')
  94. screen:expect([[
  95. {1:>>}{6: 1 }a |
  96. {2: }{6: 2 }{8:b }|
  97. {2: }{7: 3 }c |
  98. {1:>>}{7: 4 }{8:^ }|
  99. {2: }{0:~ }|
  100. {2: }{0:~ }|
  101. {2: }{0:~ }|
  102. {2: }{0:~ }|
  103. {2: }{0:~ }|
  104. {2: }{0:~ }|
  105. {2: }{0:~ }|
  106. {2: }{0:~ }|
  107. {2: }{0:~ }|
  108. |
  109. ]])
  110. end)
  111. it('can have 32bit sign IDs', function()
  112. command('sign define piet text=>> texthl=Search')
  113. command('sign place 100000 line=1 name=piet buffer=1')
  114. feed(':sign place<cr>')
  115. screen:expect([[
  116. {1:>>} |
  117. {2: }{0:~ }|
  118. {2: }{0:~ }|
  119. {2: }{0:~ }|
  120. {2: }{0:~ }|
  121. {2: }{0:~ }|
  122. {2: }{0:~ }|
  123. {4: }|
  124. :sign place |
  125. {9:--- Signs ---} |
  126. {10:Signs for [NULL]:} |
  127. line=1 id=100000 name=piet |
  128. |
  129. {11:Press ENTER or type command to continue}^ |
  130. ]])
  131. feed('<cr>')
  132. screen:expect([[
  133. {1:>>}^ |
  134. {2: }{0:~ }|
  135. {2: }{0:~ }|
  136. {2: }{0:~ }|
  137. {2: }{0:~ }|
  138. {2: }{0:~ }|
  139. {2: }{0:~ }|
  140. {2: }{0:~ }|
  141. {2: }{0:~ }|
  142. {2: }{0:~ }|
  143. {2: }{0:~ }|
  144. {2: }{0:~ }|
  145. {2: }{0:~ }|
  146. |
  147. ]])
  148. end)
  149. end)
  150. end)