2016-02-12 12:07:53 -07:00
|
|
|
-- Test for character searches
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2016-02-12 12:07:53 -07:00
|
|
|
local feed, insert = helpers.feed, helpers.insert
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
|
2016-02-12 12:07:53 -07:00
|
|
|
|
|
|
|
describe('charsearch', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
insert([[
|
|
|
|
Xabcdefghijkemnopqretuvwxyz
|
|
|
|
Yabcdefghijkemnopqretuvwxyz
|
|
|
|
Zabcdefghijkemnokqretkvwxyz]])
|
|
|
|
|
|
|
|
-- Check that "fe" and ";" work.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('/^X')
|
2016-02-12 12:07:53 -07:00
|
|
|
feed('ylfep;;p,,p')
|
|
|
|
-- Check that save/restore works.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('/^Y')
|
2016-02-12 12:07:53 -07:00
|
|
|
feed('ylfep')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let csave = getcharsearch()')
|
2016-02-12 12:07:53 -07:00
|
|
|
feed('fip')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call setcharsearch(csave)')
|
2016-02-12 12:07:53 -07:00
|
|
|
feed(';p;p')
|
2016-02-13 03:40:03 -07:00
|
|
|
-- Check that setcharsearch() changes the settings.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('/^Z')
|
2016-02-12 12:07:53 -07:00
|
|
|
feed('ylfep')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command("call setcharsearch({'char': 'k'})")
|
2016-02-12 12:07:53 -07:00
|
|
|
feed(';p')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command("call setcharsearch({'forward': 0})")
|
2016-02-12 12:07:53 -07:00
|
|
|
feed('$;p')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command("call setcharsearch({'until': 1})")
|
2016-02-12 12:07:53 -07:00
|
|
|
feed(';;p')
|
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
|
|
|
XabcdeXfghijkeXmnopqreXtuvwxyz
|
|
|
|
YabcdeYfghiYjkeYmnopqreYtuvwxyz
|
2016-02-13 03:40:03 -07:00
|
|
|
ZabcdeZfghijkZZemnokqretkZvwxyz]])
|
2016-02-12 12:07:53 -07:00
|
|
|
end)
|
|
|
|
end)
|