015_alignment_spec.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. -- Tests for :right on text with embedded TAB.
  2. -- Also test formatting a paragraph.
  3. -- Also test undo after ":%s" and formatting.
  4. local n = require('test.functional.testnvim')()
  5. local feed, insert = n.feed, n.insert
  6. local clear, feed_command, expect = n.clear, n.feed_command, n.expect
  7. describe('alignment', function()
  8. setup(clear)
  9. -- luacheck: ignore 621 (Indentation)
  10. it('is working', function()
  11. insert([[
  12. test for :left
  13. a a
  14. fa a
  15. dfa a
  16. sdfa a
  17. asdfa a
  18. xasdfa a
  19. asxxdfa a
  20. test for :center
  21. a a
  22. fa afd asdf
  23. dfa a
  24. sdfa afd asdf
  25. asdfa a
  26. xasdfa asdfasdfasdfasdfasdf
  27. asxxdfa a
  28. test for :right
  29. a a
  30. fa a
  31. dfa a
  32. sdfa a
  33. asdfa a
  34. xasdfa a
  35. asxxdfa a
  36. asxa;ofa a
  37. asdfaqwer a
  38. a ax
  39. fa ax
  40. dfa ax
  41. sdfa ax
  42. asdfa ax
  43. xasdfa ax
  44. asxxdfa ax
  45. asxa;ofa ax
  46. asdfaqwer ax
  47. a axx
  48. fa axx
  49. dfa axx
  50. sdfa axx
  51. asdfa axx
  52. xasdfa axx
  53. asxxdfa axx
  54. asxa;ofa axx
  55. asdfaqwer axx
  56. a axxx
  57. fa axxx
  58. dfa axxx
  59. sdfa axxx
  60. asdfa axxx
  61. xasdfa axxx
  62. asxxdfa axxx
  63. asxa;ofa axxx
  64. asdfaqwer axxx
  65. a axxxo
  66. fa axxxo
  67. dfa axxxo
  68. sdfa axxxo
  69. asdfa axxxo
  70. xasdfa axxxo
  71. asxxdfa axxxo
  72. asxa;ofa axxxo
  73. asdfaqwer axxxo
  74. a axxxoi
  75. fa axxxoi
  76. dfa axxxoi
  77. sdfa axxxoi
  78. asdfa axxxoi
  79. xasdfa axxxoi
  80. asxxdfa axxxoi
  81. asxa;ofa axxxoi
  82. asdfaqwer axxxoi
  83. a axxxoik
  84. fa axxxoik
  85. dfa axxxoik
  86. sdfa axxxoik
  87. asdfa axxxoik
  88. xasdfa axxxoik
  89. asxxdfa axxxoik
  90. asxa;ofa axxxoik
  91. asdfaqwer axxxoik
  92. a axxxoike
  93. fa axxxoike
  94. dfa axxxoike
  95. sdfa axxxoike
  96. asdfa axxxoike
  97. xasdfa axxxoike
  98. asxxdfa axxxoike
  99. asxa;ofa axxxoike
  100. asdfaqwer axxxoike
  101. a axxxoikey
  102. fa axxxoikey
  103. dfa axxxoikey
  104. sdfa axxxoikey
  105. asdfa axxxoikey
  106. xasdfa axxxoikey
  107. asxxdfa axxxoikey
  108. asxa;ofa axxxoikey
  109. asdfaqwer axxxoikey
  110. xxxxx xx xxxxxx
  111. xxxxxxx xxxxxxxxx xxx xxxx xxxxx xxxxx xxx xx
  112. xxxxxxxxxxxxxxxxxx xxxxx xxxx, xxxx xxxx xxxx xxxx xxx xx xx
  113. xx xxxxxxx. xxxx xxxx.
  114. > xx xx, xxxx xxxx xxx xxxx xxx xxxxx xxx xxx xxxxxxx xxx xxxxx
  115. > xxxxxx xxxxxxx: xxxx xxxxxxx, xx xxxxxx xxxx xxxxxxxxxx
  116. aa aa aa aa
  117. bb bb bb bb
  118. cc cc cc cc]])
  119. feed_command('set tw=65')
  120. feed([[:/^\s*test for :left/,/^\s*test for :center/ left<cr>]])
  121. feed([[:/^\s*test for :center/,/^\s*test for :right/ center<cr>]])
  122. feed([[:/^\s*test for :right/,/^xxx/-1 right<cr>]])
  123. feed_command('set fo+=tcroql tw=72')
  124. feed('/xxxxxxxx$<cr>')
  125. feed('0gq6kk<cr>')
  126. -- Undo/redo here to make the next undo only work on the following changes.
  127. feed('u<cr>')
  128. feed_command('map gg :.,.+2s/^/x/<CR>kk:set tw=3<CR>gqq')
  129. feed_command('/^aa')
  130. feed('ggu<cr>')
  131. -- Assert buffer contents.
  132. expect([[
  133. test for :left
  134. a a
  135. fa a
  136. dfa a
  137. sdfa a
  138. asdfa a
  139. xasdfa a
  140. asxxdfa a
  141. test for :center
  142. a a
  143. fa afd asdf
  144. dfa a
  145. sdfa afd asdf
  146. asdfa a
  147. xasdfa asdfasdfasdfasdfasdf
  148. asxxdfa a
  149. test for :right
  150. a a
  151. fa a
  152. dfa a
  153. sdfa a
  154. asdfa a
  155. xasdfa a
  156. asxxdfa a
  157. asxa;ofa a
  158. asdfaqwer a
  159. a ax
  160. fa ax
  161. dfa ax
  162. sdfa ax
  163. asdfa ax
  164. xasdfa ax
  165. asxxdfa ax
  166. asxa;ofa ax
  167. asdfaqwer ax
  168. a axx
  169. fa axx
  170. dfa axx
  171. sdfa axx
  172. asdfa axx
  173. xasdfa axx
  174. asxxdfa axx
  175. asxa;ofa axx
  176. asdfaqwer axx
  177. a axxx
  178. fa axxx
  179. dfa axxx
  180. sdfa axxx
  181. asdfa axxx
  182. xasdfa axxx
  183. asxxdfa axxx
  184. asxa;ofa axxx
  185. asdfaqwer axxx
  186. a axxxo
  187. fa axxxo
  188. dfa axxxo
  189. sdfa axxxo
  190. asdfa axxxo
  191. xasdfa axxxo
  192. asxxdfa axxxo
  193. asxa;ofa axxxo
  194. asdfaqwer axxxo
  195. a axxxoi
  196. fa axxxoi
  197. dfa axxxoi
  198. sdfa axxxoi
  199. asdfa axxxoi
  200. xasdfa axxxoi
  201. asxxdfa axxxoi
  202. asxa;ofa axxxoi
  203. asdfaqwer axxxoi
  204. a axxxoik
  205. fa axxxoik
  206. dfa axxxoik
  207. sdfa axxxoik
  208. asdfa axxxoik
  209. xasdfa axxxoik
  210. asxxdfa axxxoik
  211. asxa;ofa axxxoik
  212. asdfaqwer axxxoik
  213. a axxxoike
  214. fa axxxoike
  215. dfa axxxoike
  216. sdfa axxxoike
  217. asdfa axxxoike
  218. xasdfa axxxoike
  219. asxxdfa axxxoike
  220. asxa;ofa axxxoike
  221. asdfaqwer axxxoike
  222. a axxxoikey
  223. fa axxxoikey
  224. dfa axxxoikey
  225. sdfa axxxoikey
  226. asdfa axxxoikey
  227. xasdfa axxxoikey
  228. asxxdfa axxxoikey
  229. asxa;ofa axxxoikey
  230. asdfaqwer axxxoikey
  231. xxxxx xx xxxxxx xxxxxxx xxxxxxxxx xxx xxxx xxxxx xxxxx xxx xx
  232. xxxxxxxxxxxxxxxxxx xxxxx xxxx, xxxx xxxx xxxx xxxx xxx xx xx xx xxxxxxx.
  233. xxxx xxxx.
  234. > xx xx, xxxx xxxx xxx xxxx xxx xxxxx xxx xxx xxxxxxx xxx xxxxx xxxxxx
  235. > xxxxxxx: xxxx xxxxxxx, xx xxxxxx xxxx xxxxxxxxxx
  236. aa aa aa aa
  237. bb bb bb bb
  238. cc cc cc cc]])
  239. end)
  240. end)