2014-11-10 06:47:57 -07:00
|
|
|
-- Test for v:hlsearch
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-11-17 14:44:00 -07:00
|
|
|
local clear, feed = helpers.clear, helpers.feed
|
2017-04-08 14:12:26 -07:00
|
|
|
local feed_command, expect = helpers.feed_command, helpers.expect
|
2014-11-10 06:47:57 -07:00
|
|
|
|
|
|
|
describe('v:hlsearch', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
-- Last abc: Q
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('new')
|
|
|
|
feed_command([[call setline(1, repeat(['aaa'], 10))]])
|
|
|
|
feed_command('set hlsearch nolazyredraw')
|
|
|
|
feed_command('let r=[]')
|
|
|
|
feed_command('command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])')
|
|
|
|
feed_command('/aaa')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('nohlsearch')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('let v:hlsearch=1')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('let v:hlsearch=0')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('set hlsearch')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('let v:hlsearch=0')
|
|
|
|
feed_command('AddR')
|
2014-11-10 06:47:57 -07:00
|
|
|
feed('n:AddR<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('let v:hlsearch=0')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('/')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('set nohls')
|
|
|
|
feed_command('/')
|
|
|
|
feed_command('AddR')
|
|
|
|
feed_command('let r1=r[0][0]')
|
2014-11-10 06:47:57 -07:00
|
|
|
|
|
|
|
-- I guess it is not guaranteed that screenattr outputs always the same character
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command([[call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')]])
|
|
|
|
feed_command('try')
|
|
|
|
feed_command(' let v:hlsearch=[]')
|
|
|
|
feed_command('catch')
|
|
|
|
feed_command([[ call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))]])
|
|
|
|
feed_command('endtry')
|
|
|
|
feed_command('bwipeout!')
|
|
|
|
feed_command('$put=r')
|
|
|
|
feed_command('call garbagecollect(1)')
|
|
|
|
feed_command('call getchar()')
|
|
|
|
feed_command('1d', '1d')
|
2014-11-10 06:47:57 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
|
|
|
1:highlighted
|
|
|
|
0:not highlighted
|
|
|
|
1:highlighted
|
|
|
|
0:not highlighted
|
|
|
|
1:highlighted
|
|
|
|
0:not highlighted
|
|
|
|
1:highlighted
|
|
|
|
0:not highlighted
|
|
|
|
1:highlighted
|
2015-04-25 11:01:33 -07:00
|
|
|
0:not highlighted
|
2016-07-13 00:56:58 -07:00
|
|
|
Vim(let):E745:]])
|
2014-11-10 06:47:57 -07:00
|
|
|
end)
|
|
|
|
end)
|