2014-10-24 14:16:18 -07:00
|
|
|
-- Some tests for buffer-local autocommands
|
|
|
|
|
2024-04-09 04:26:16 -07:00
|
|
|
local t = require('test.functional.testutil')()
|
2017-04-08 12:33:02 -07:00
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
local clear = t.clear
|
|
|
|
local expect = t.expect
|
|
|
|
local command = t.command
|
2017-04-08 12:33:02 -07:00
|
|
|
|
|
|
|
local fname = 'Xtest-functional-legacy-054'
|
2014-10-24 14:16:18 -07:00
|
|
|
|
|
|
|
describe('BufLeave <buffer>', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
2017-04-08 12:33:02 -07:00
|
|
|
command('write! ' .. fname)
|
|
|
|
command('autocmd BufLeave <buffer> normal! Ibuffer-local autocommand')
|
|
|
|
command('autocmd BufLeave <buffer> update')
|
|
|
|
|
2014-10-24 14:16:18 -07:00
|
|
|
-- Here, autocommand for xx shall append a line
|
2017-02-28 09:39:23 -07:00
|
|
|
-- But autocommand shall not apply to buffer named <buffer>
|
2017-04-08 12:33:02 -07:00
|
|
|
command('edit somefile')
|
2014-10-24 14:16:18 -07:00
|
|
|
|
|
|
|
-- Here, autocommand shall be auto-deleted
|
2017-04-08 12:33:02 -07:00
|
|
|
command('bwipeout ' .. fname)
|
|
|
|
|
2014-10-24 14:16:18 -07:00
|
|
|
-- Nothing shall be written
|
2017-04-08 12:33:02 -07:00
|
|
|
command('edit ' .. fname)
|
|
|
|
command('edit somefile')
|
|
|
|
command('edit ' .. fname)
|
2014-10-24 14:16:18 -07:00
|
|
|
|
2017-04-08 12:33:02 -07:00
|
|
|
expect('buffer-local autocommand')
|
2014-10-24 14:16:18 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
teardown(function()
|
2017-04-08 12:33:02 -07:00
|
|
|
os.remove(fname)
|
2014-10-24 14:16:18 -07:00
|
|
|
end)
|
|
|
|
end)
|