listlbr_spec.lua 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. -- Test for linebreak and list option (non-utf8)
  2. local helpers = require('test.functional.helpers')(after_each)
  3. local feed, insert, source = helpers.feed, helpers.insert, helpers.source
  4. local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
  5. describe('listlbr', function()
  6. setup(clear)
  7. -- luacheck: ignore 621 (Indentation)
  8. -- luacheck: ignore 611 (Line contains only whitespaces)
  9. -- luacheck: ignore 613 (Trailing whitespaces in a string)
  10. it('is working', function()
  11. insert([[
  12. dummy text]])
  13. feed_command('set wildchar=^E')
  14. feed_command('10new')
  15. feed_command('vsp')
  16. feed_command('vert resize 20')
  17. feed_command([[put =\"\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP \"]])
  18. feed_command('norm! zt')
  19. feed_command('set ts=4 sw=4 sts=4 linebreak sbr=+ wrap')
  20. source([[
  21. fu! ScreenChar(width)
  22. let c=''
  23. for j in range(1,4)
  24. for i in range(1,a:width)
  25. let c.=nr2char(screenchar(j, i))
  26. endfor
  27. let c.="\n"
  28. endfor
  29. return c
  30. endfu
  31. fu! DoRecordScreen()
  32. wincmd l
  33. $put =printf(\"\n%s\", g:test)
  34. $put =g:line
  35. wincmd p
  36. endfu
  37. ]])
  38. feed_command('let g:test="Test 1: set linebreak"')
  39. feed_command('redraw!')
  40. feed_command('let line=ScreenChar(winwidth(0))')
  41. feed_command('call DoRecordScreen()')
  42. feed_command('let g:test="Test 2: set linebreak + set list"')
  43. feed_command('set linebreak list listchars=')
  44. feed_command('redraw!')
  45. feed_command('let line=ScreenChar(winwidth(0))')
  46. feed_command('call DoRecordScreen()')
  47. feed_command('let g:test ="Test 3: set linebreak nolist"')
  48. feed_command('set nolist linebreak')
  49. feed_command('redraw!')
  50. feed_command('let line=ScreenChar(winwidth(0))')
  51. feed_command('call DoRecordScreen()')
  52. feed_command('let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"')
  53. feed_command('set nolist linebreak ts=8')
  54. feed_command([[let line="1\t".repeat('a', winwidth(0)-2)]])
  55. feed_command('$put =line')
  56. feed_command('$')
  57. feed_command('norm! zt')
  58. feed_command('redraw!')
  59. feed_command('let line=ScreenChar(winwidth(0))')
  60. feed_command('call DoRecordScreen()')
  61. feed_command([[let line="_S_\t bla"]])
  62. feed_command('$put =line')
  63. feed_command('$')
  64. feed_command('norm! zt')
  65. feed_command('let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"')
  66. feed_command('set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab')
  67. feed_command('syn match ConcealVar contained /_/ conceal')
  68. feed_command('syn match All /.*/ contains=ConcealVar')
  69. feed_command('let line=ScreenChar(winwidth(0))')
  70. feed_command('call DoRecordScreen()')
  71. feed_command('set cpo&vim linebreak')
  72. feed_command('let g:test ="Test 6: set linebreak with visual block mode"')
  73. feed_command('let line="REMOVE: this not"')
  74. feed_command('$put =g:test')
  75. feed_command('$put =line')
  76. feed_command('let line="REMOVE: aaaaaaaaaaaaa"')
  77. feed_command('$put =line')
  78. feed_command('1/^REMOVE:')
  79. feed('0<C-V>jf x')
  80. feed_command('$put')
  81. feed_command('set cpo&vim linebreak')
  82. feed_command('let g:test ="Test 7: set linebreak with visual block mode and v_b_A"')
  83. feed_command('$put =g:test')
  84. feed('Golong line: <esc>40afoobar <esc>aTARGET at end<esc>')
  85. feed_command([[exe "norm! $3B\<C-v>eAx\<Esc>"]])
  86. feed_command('set cpo&vim linebreak sbr=')
  87. feed_command('let g:test ="Test 8: set linebreak with visual char mode and changing block"')
  88. feed_command('$put =g:test')
  89. feed('Go1111-1111-1111-11-1111-1111-1111<esc>0f-lv3lc2222<esc>bgj.')
  90. feed_command('let g:test ="Test 9: using redo after block visual mode"')
  91. feed_command('$put =g:test')
  92. feed('Go<CR>')
  93. feed('aaa<CR>')
  94. feed('aaa<CR>')
  95. feed('a<ESC>2k<C-V>2j~e.<CR>')
  96. feed_command('let g:test ="Test 10: using normal commands after block-visual"')
  97. feed_command('$put =g:test')
  98. feed_command('set linebreak')
  99. feed('Go<cr>')
  100. feed('abcd{ef<cr>')
  101. feed('ghijklm<cr>')
  102. feed('no}pqrs<esc>2k0f{<C-V><C-V>c%<esc>')
  103. feed_command('let g:test ="Test 11: using block replace mode after wrapping"')
  104. feed_command('$put =g:test')
  105. feed_command('set linebreak wrap')
  106. feed('Go<esc>150aa<esc>yypk147|<C-V>jr0<cr>')
  107. feed_command('let g:test ="Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$"')
  108. feed_command('set list listchars=space:_,trail:-,tab:>-,eol:$')
  109. feed_command('$put =g:test')
  110. feed_command([[let line="a aaaaaaaaaaaaaaaaaaaaaa\ta "]])
  111. feed_command('$put =line')
  112. feed_command('$')
  113. feed_command('norm! zt')
  114. feed_command('redraw!')
  115. feed_command('let line=ScreenChar(winwidth(0))')
  116. feed_command('call DoRecordScreen()')
  117. -- Assert buffer contents.
  118. expect([[
  119. abcdef hijklmn pqrstuvwxyz_1060ABCDEFGHIJKLMNOP
  120. Test 1: set linebreak
  121. abcdef
  122. +hijklmn
  123. +pqrstuvwxyz_1060ABC
  124. +DEFGHIJKLMNOP
  125. Test 2: set linebreak + set list
  126. ^Iabcdef hijklmn^I
  127. +pqrstuvwxyz_1060ABC
  128. +DEFGHIJKLMNOP
  129. Test 3: set linebreak nolist
  130. abcdef
  131. +hijklmn
  132. +pqrstuvwxyz_1060ABC
  133. +DEFGHIJKLMNOP
  134. 1 aaaaaaaaaaaaaaaaaa
  135. Test 4: set linebreak with tab and 1 line as long as screen: should break!
  136. 1
  137. +aaaaaaaaaaaaaaaaaa
  138. ~
  139. ~
  140. _S_ bla
  141. Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)
  142. Sabbbbbb bla
  143. ~
  144. ~
  145. ~
  146. Test 6: set linebreak with visual block mode
  147. this not
  148. aaaaaaaaaaaaa
  149. REMOVE:
  150. REMOVE:
  151. Test 7: set linebreak with visual block mode and v_b_A
  152. long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETx at end
  153. Test 8: set linebreak with visual char mode and changing block
  154. 1111-2222-1111-11-1111-2222-1111
  155. Test 9: using redo after block visual mode
  156. AaA
  157. AaA
  158. A
  159. Test 10: using normal commands after block-visual
  160. abcdpqrs
  161. Test 11: using block replace mode after wrapping
  162. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
  163. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
  164. Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
  165. a aaaaaaaaaaaaaaaaaaaaaa a
  166. Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
  167. a_
  168. aaaaaaaaaaaaaaaaaaaa
  169. aa>-----a-$
  170. ~ ]])
  171. end)
  172. end)