fold_spec.lua 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq
  4. local feed_command = helpers.feed_command
  5. local insert = helpers.insert
  6. local meths = helpers.meths
  7. describe("folded lines", function()
  8. local screen
  9. before_each(function()
  10. clear()
  11. screen = Screen.new(45, 8)
  12. screen:attach({rgb=true})
  13. screen:set_default_attr_ids({
  14. [1] = {bold = true, foreground = Screen.colors.Blue1},
  15. [2] = {reverse = true},
  16. [3] = {bold = true, reverse = true},
  17. [4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  18. [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
  19. [6] = {background = Screen.colors.Yellow},
  20. [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  21. })
  22. end)
  23. after_each(function()
  24. screen:detach()
  25. end)
  26. it("works with multibyte text", function()
  27. -- Currently the only allowed value of 'maxcombine'
  28. eq(6, meths.get_option('maxcombine'))
  29. eq(true, meths.get_option('arabicshape'))
  30. insert([[
  31. å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة
  32. möre text]])
  33. screen:expect([[
  34. å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ |
  35. möre tex^t |
  36. {1:~ }|
  37. {1:~ }|
  38. {1:~ }|
  39. {1:~ }|
  40. {1:~ }|
  41. |
  42. ]])
  43. feed('vkzf')
  44. screen:expect([[
  45. {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}|
  46. {1:~ }|
  47. {1:~ }|
  48. {1:~ }|
  49. {1:~ }|
  50. {1:~ }|
  51. {1:~ }|
  52. |
  53. ]])
  54. feed_command("set noarabicshape")
  55. screen:expect([[
  56. {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة·················}|
  57. {1:~ }|
  58. {1:~ }|
  59. {1:~ }|
  60. {1:~ }|
  61. {1:~ }|
  62. {1:~ }|
  63. :set noarabicshape |
  64. ]])
  65. feed_command("set number foldcolumn=2")
  66. screen:expect([[
  67. {7:+ }{5: 1 ^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة···········}|
  68. {7: }{1:~ }|
  69. {7: }{1:~ }|
  70. {7: }{1:~ }|
  71. {7: }{1:~ }|
  72. {7: }{1:~ }|
  73. {7: }{1:~ }|
  74. :set number foldcolumn=2 |
  75. ]])
  76. -- Note: too much of the folded line gets cut off.This is a vim bug.
  77. feed_command("set rightleft")
  78. screen:expect([[
  79. {5:+-- 2 lines: å ······················^· 1 }{7: +}|
  80. {1: ~}{7: }|
  81. {1: ~}{7: }|
  82. {1: ~}{7: }|
  83. {1: ~}{7: }|
  84. {1: ~}{7: }|
  85. {1: ~}{7: }|
  86. :set rightleft |
  87. ]])
  88. feed_command("set nonumber foldcolumn=0")
  89. screen:expect([[
  90. {5:+-- 2 lines: å 语 x̎͂̀̂͛͛ ال·····················^·}|
  91. {1: ~}|
  92. {1: ~}|
  93. {1: ~}|
  94. {1: ~}|
  95. {1: ~}|
  96. {1: ~}|
  97. :set nonumber foldcolumn=0 |
  98. ]])
  99. feed_command("set arabicshape")
  100. screen:expect([[
  101. {5:+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺍﻟ·····················^·}|
  102. {1: ~}|
  103. {1: ~}|
  104. {1: ~}|
  105. {1: ~}|
  106. {1: ~}|
  107. {1: ~}|
  108. :set arabicshape |
  109. ]])
  110. feed('zo')
  111. screen:expect([[
  112. ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̎͂̀̂͛͛ 语 å|
  113. txet eröm|
  114. {1: ~}|
  115. {1: ~}|
  116. {1: ~}|
  117. {1: ~}|
  118. {1: ~}|
  119. :set arabicshape |
  120. ]])
  121. feed_command('set noarabicshape')
  122. screen:expect([[
  123. ةيَّبِرَعَ^لا x̎͂̀̂͛͛ 语 å|
  124. txet eröm|
  125. {1: ~}|
  126. {1: ~}|
  127. {1: ~}|
  128. {1: ~}|
  129. {1: ~}|
  130. :set noarabicshape |
  131. ]])
  132. end)
  133. it("work in cmdline window", function()
  134. feed_command("set foldmethod=manual")
  135. feed_command("let x = 1")
  136. feed_command("/alpha")
  137. feed_command("/omega")
  138. feed("<cr>q:")
  139. screen:expect([[
  140. |
  141. {2:[No Name] }|
  142. {1::}set foldmethod=manual |
  143. {1::}let x = 1 |
  144. {1::}^ |
  145. {1::~ }|
  146. {3:[Command Line] }|
  147. : |
  148. ]])
  149. feed("kzfk")
  150. screen:expect([[
  151. |
  152. {2:[No Name] }|
  153. {1::}{5:^+-- 2 lines: set foldmethod=manual·········}|
  154. {1::} |
  155. {1::~ }|
  156. {1::~ }|
  157. {3:[Command Line] }|
  158. : |
  159. ]])
  160. feed("<cr>")
  161. screen:expect([[
  162. ^ |
  163. {1:~ }|
  164. {1:~ }|
  165. {1:~ }|
  166. {1:~ }|
  167. {1:~ }|
  168. {1:~ }|
  169. : |
  170. ]])
  171. feed("/<c-f>")
  172. screen:expect([[
  173. |
  174. {2:[No Name] }|
  175. {1:/}alpha |
  176. {1:/}{6:omega} |
  177. {1:/}^ |
  178. {1:/~ }|
  179. {3:[Command Line] }|
  180. / |
  181. ]])
  182. feed("ggzfG")
  183. screen:expect([[
  184. |
  185. {2:[No Name] }|
  186. {1:/}{5:^+-- 3 lines: alpha·························}|
  187. {1:/~ }|
  188. {1:/~ }|
  189. {1:/~ }|
  190. {3:[Command Line] }|
  191. / |
  192. ]])
  193. end)
  194. end)