2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
2021-08-17 06:56:37 -07:00
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local clear = n.clear
|
2024-04-08 02:03:20 -07:00
|
|
|
local eq = t.eq
|
2024-04-20 08:44:13 -07:00
|
|
|
local eval = n.eval
|
|
|
|
local source_vim = n.source
|
2021-08-17 06:56:37 -07:00
|
|
|
|
|
|
|
describe('RecordingEnter', function()
|
|
|
|
before_each(clear)
|
|
|
|
it('works', function()
|
|
|
|
source_vim [[
|
|
|
|
let g:recorded = 0
|
|
|
|
autocmd RecordingEnter * let g:recorded += 1
|
2022-01-04 18:55:29 -07:00
|
|
|
call feedkeys("qqyyq", 'xt')
|
2021-08-17 06:56:37 -07:00
|
|
|
]]
|
|
|
|
eq(1, eval('g:recorded'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('gives a correct reg_recording()', function()
|
|
|
|
source_vim [[
|
|
|
|
let g:recording = ''
|
|
|
|
autocmd RecordingEnter * let g:recording = reg_recording()
|
2022-01-04 18:55:29 -07:00
|
|
|
call feedkeys("qqyyq", 'xt')
|
2021-08-17 06:56:37 -07:00
|
|
|
]]
|
|
|
|
eq('q', eval('g:recording'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('RecordingLeave', function()
|
|
|
|
before_each(clear)
|
|
|
|
it('works', function()
|
|
|
|
source_vim [[
|
|
|
|
let g:recorded = 0
|
|
|
|
autocmd RecordingLeave * let g:recorded += 1
|
2022-01-04 18:55:29 -07:00
|
|
|
call feedkeys("qqyyq", 'xt')
|
2021-08-17 06:56:37 -07:00
|
|
|
]]
|
|
|
|
eq(1, eval('g:recorded'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('gives the correct reg_recorded()', function()
|
|
|
|
source_vim [[
|
|
|
|
let g:recorded = 'a'
|
|
|
|
let g:recording = ''
|
|
|
|
autocmd RecordingLeave * let g:recording = reg_recording()
|
|
|
|
autocmd RecordingLeave * let g:recorded = reg_recorded()
|
2022-01-04 18:55:29 -07:00
|
|
|
call feedkeys("qqyyq", 'xt')
|
2021-08-17 06:56:37 -07:00
|
|
|
]]
|
|
|
|
eq('q', eval 'g:recording')
|
|
|
|
eq('', eval 'g:recorded')
|
|
|
|
eq('q', eval 'reg_recorded()')
|
|
|
|
end)
|
2022-01-04 18:55:29 -07:00
|
|
|
|
|
|
|
it('populates v:event', function()
|
|
|
|
source_vim [[
|
|
|
|
let g:regname = ''
|
|
|
|
let g:regcontents = ''
|
|
|
|
autocmd RecordingLeave * let g:regname = v:event.regname
|
|
|
|
autocmd RecordingLeave * let g:regcontents = v:event.regcontents
|
|
|
|
call feedkeys("qqyyq", 'xt')
|
|
|
|
]]
|
|
|
|
eq('q', eval 'g:regname')
|
|
|
|
eq('yy', eval 'g:regcontents')
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('resets v:event', function()
|
|
|
|
source_vim [[
|
|
|
|
autocmd RecordingLeave * let g:event = v:event
|
|
|
|
call feedkeys("qqyyq", 'xt')
|
|
|
|
]]
|
|
|
|
eq(0, eval 'len(v:event)')
|
|
|
|
end)
|
2021-08-17 06:56:37 -07:00
|
|
|
end)
|