123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- local helpers = require('test.functional.helpers')(after_each)
- local feed = helpers.feed
- local clear = helpers.clear
- local insert = helpers.insert
- local feed_command = helpers.feed_command
- local expect = helpers.expect
- describe('text formatting', function()
- setup(clear)
- -- luacheck: ignore 613 (Trailing whitespace in a string)
- it('is working', function()
- -- The control character <C-A> (byte \x01) needs to be put in the buffer
- -- directly. But the insert function sends the text to nvim in insert
- -- mode so it has to be escaped with <C-V>.
- insert([[
- Results of test68:
- {
- }
- {
- a b
- a
- }
- {
- a
- }
- {
- a b
- #a b
- }
- {
- 1 a
- # 1 a
- }
- {
- x a
- b
- c
- }
- {
- # 1 a b
- }
- {
- # x
- # a b
- }
- {
- 1aa
- 2bb
- }
- /* abc def ghi jkl
- * mno pqr stu
- */
- # 1 xxxxx
- ]])
- feed_command('/^{/+1')
- feed_command('set noai tw=2 fo=t')
- feed('gRa b<esc>')
- feed_command('/^{/+1')
- feed_command('set ai tw=2 fo=tw')
- feed('gqgqjjllab<esc>')
- feed_command('/^{/+1')
- feed_command('set tw=3 fo=t')
- feed('gqgqo<cr>')
- feed('a <C-V><C-A><esc><esc>')
- feed_command('/^{/+1')
- feed_command('set tw=2 fo=tcq1 comments=:#')
- feed('gqgqjgqgqo<cr>')
- feed('a b<cr>')
- feed('#a b<esc>')
- feed_command('/^{/+1')
- feed_command('set tw=5 fo=tcn comments=:#')
- feed('A b<esc>jA b<esc>')
- feed_command('/^{/+3')
- feed_command('set tw=5 fo=t2a si')
- feed('i <esc>A_<esc>')
- feed_command('/^{/+1')
- feed_command('set tw=5 fo=qn comments=:#')
- feed('gwap<cr>')
- feed_command('/^{/+1')
- feed_command('set tw=5 fo=q2 comments=:#')
- feed('gwap<cr>')
- feed_command('/^{/+2')
- feed_command('set tw& fo=a')
- feed('I^^<esc><esc>')
- feed_command('/mno pqr/')
- feed_command('setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/')
- feed('A vwx yz<esc>')
- feed_command('/^#/')
- feed_command('setl tw=12 fo=tqnc comments=:#')
- feed('A foobar<esc>')
- -- Assert buffer contents.
- expect([[
- Results of test68:
- {
- a
- b
- }
- {
- a
- b
- a
- b
- }
- {
- a
-
- a
-
- }
- {
- a b
- #a b
- a b
- #a b
- }
- {
- 1 a
- b
- # 1 a
- # b
- }
- {
- x a
- b_
- c
- }
- {
- # 1 a
- # b
- }
- {
- # x a
- # b
- }
- { 1aa ^^2bb }
- /* abc def ghi jkl
- * mno pqr stu
- * vwx yz
- */
- # 1 xxxxx
- # foobar
- ]])
- end)
- end)
|