2014-11-10 06:47:57 -07:00
|
|
|
-- Test for v:hlsearch
|
|
|
|
|
|
|
|
local helpers = require('test.functional.helpers')
|
|
|
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
|
|
|
local execute, expect = helpers.execute, helpers.expect
|
2014-11-21 09:06:03 -07:00
|
|
|
local eval = helpers.eval
|
2014-11-10 06:47:57 -07:00
|
|
|
|
|
|
|
describe('v:hlsearch', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
-- Last abc: Q
|
|
|
|
execute('new')
|
|
|
|
execute([[call setline(1, repeat(['aaa'], 10))]])
|
|
|
|
execute('set hlsearch nolazyredraw')
|
|
|
|
execute('let r=[]')
|
|
|
|
execute('command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])')
|
|
|
|
execute('/aaa')
|
|
|
|
execute('AddR')
|
|
|
|
execute('nohlsearch')
|
|
|
|
execute('AddR')
|
|
|
|
execute('let v:hlsearch=1')
|
|
|
|
execute('AddR')
|
|
|
|
execute('let v:hlsearch=0')
|
|
|
|
execute('AddR')
|
|
|
|
execute('set hlsearch')
|
|
|
|
execute('AddR')
|
|
|
|
execute('let v:hlsearch=0')
|
|
|
|
execute('AddR')
|
|
|
|
feed('n:AddR<cr>')
|
|
|
|
execute('let v:hlsearch=0')
|
|
|
|
execute('AddR')
|
|
|
|
execute('/')
|
|
|
|
execute('AddR')
|
2015-04-25 11:01:33 -07:00
|
|
|
execute('set nohls')
|
|
|
|
execute('/')
|
|
|
|
execute('AddR')
|
2014-11-10 06:47:57 -07:00
|
|
|
execute('let r1=r[0][0]')
|
|
|
|
|
|
|
|
-- I guess it is not guaranteed that screenattr outputs always the same character
|
|
|
|
execute([[call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')]])
|
|
|
|
execute('try')
|
|
|
|
execute(' let v:hlsearch=[]')
|
|
|
|
execute('catch')
|
|
|
|
execute([[ call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))]])
|
|
|
|
execute('endtry')
|
|
|
|
execute('bwipeout!')
|
|
|
|
execute('$put=r')
|
|
|
|
execute('call garbagecollect(1)')
|
|
|
|
execute('call getchar()')
|
2014-11-21 09:06:03 -07:00
|
|
|
execute('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
|
2014-11-10 06:47:57 -07:00
|
|
|
Vim(let):E706:]])
|
|
|
|
end)
|
|
|
|
end)
|