2016-04-23 16:53:11 -07:00
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
|
|
|
|
|
|
local feed = helpers.feed
|
|
|
|
|
local clear = helpers.clear
|
|
|
|
|
local insert = helpers.insert
|
2017-04-08 14:12:26 -07:00
|
|
|
|
local feed_command = helpers.feed_command
|
2016-04-23 16:53:11 -07:00
|
|
|
|
local expect = helpers.expect
|
2015-05-15 10:03:48 -07:00
|
|
|
|
|
|
|
|
|
describe('text formatting', function()
|
|
|
|
|
setup(clear)
|
|
|
|
|
|
2017-09-24 11:42:48 -07:00
|
|
|
|
-- luacheck: ignore 613 (Trailing whitespace in a string)
|
2015-05-15 10:03:48 -07:00
|
|
|
|
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:
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
a b
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
a
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
a
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
a b
|
|
|
|
|
#a b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
1 a
|
|
|
|
|
# 1 a
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
x a
|
|
|
|
|
b
|
|
|
|
|
c
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
# 1 a b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
# x
|
|
|
|
|
# a b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
1aa
|
|
|
|
|
2bb
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
/* abc def ghi jkl
|
|
|
|
|
* mno pqr stu
|
|
|
|
|
*/
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
# 1 xxxxx
|
|
|
|
|
]])
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+1')
|
|
|
|
|
feed_command('set noai tw=2 fo=t')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('gRa b<esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+1')
|
|
|
|
|
feed_command('set ai tw=2 fo=tw')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('gqgqjjllab<esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+1')
|
|
|
|
|
feed_command('set tw=3 fo=t')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('gqgqo<cr>')
|
|
|
|
|
feed('a <C-V><C-A><esc><esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+1')
|
|
|
|
|
feed_command('set tw=2 fo=tcq1 comments=:#')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('gqgqjgqgqo<cr>')
|
|
|
|
|
feed('a b<cr>')
|
|
|
|
|
feed('#a b<esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+1')
|
|
|
|
|
feed_command('set tw=5 fo=tcn comments=:#')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('A b<esc>jA b<esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+3')
|
|
|
|
|
feed_command('set tw=5 fo=t2a si')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('i <esc>A_<esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+1')
|
|
|
|
|
feed_command('set tw=5 fo=qn comments=:#')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('gwap<cr>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+1')
|
|
|
|
|
feed_command('set tw=5 fo=q2 comments=:#')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('gwap<cr>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^{/+2')
|
|
|
|
|
feed_command('set tw& fo=a')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('I^^<esc><esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/mno pqr/')
|
|
|
|
|
feed_command('setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('A vwx yz<esc>')
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('/^#/')
|
|
|
|
|
feed_command('setl tw=12 fo=tqnc comments=:#')
|
2015-05-15 10:03:48 -07:00
|
|
|
|
feed('A foobar<esc>')
|
|
|
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
|
expect([[
|
|
|
|
|
Results of test68:
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
a
|
|
|
|
|
b
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
a
|
|
|
|
|
b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
a
|
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
a
|
|
|
|
|
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
a b
|
|
|
|
|
#a b
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
a b
|
|
|
|
|
#a b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
1 a
|
|
|
|
|
b
|
|
|
|
|
# 1 a
|
|
|
|
|
# b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
x a
|
|
|
|
|
b_
|
|
|
|
|
c
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
# 1 a
|
|
|
|
|
# b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{
|
|
|
|
|
# x a
|
|
|
|
|
# b
|
|
|
|
|
}
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
{ 1aa ^^2bb }
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
/* abc def ghi jkl
|
|
|
|
|
* mno pqr stu
|
|
|
|
|
* vwx yz
|
|
|
|
|
*/
|
2017-04-08 14:12:26 -07:00
|
|
|
|
|
|
|
|
|
|
2015-05-15 10:03:48 -07:00
|
|
|
|
# 1 xxxxx
|
|
|
|
|
# foobar
|
|
|
|
|
]])
|
|
|
|
|
end)
|
|
|
|
|
end)
|