2014-11-06 16:21:03 -07:00
|
|
|
-- Test for autocommand that deletes the current buffer on BufLeave event.
|
|
|
|
-- Also test deleting the last buffer, should give a new, empty buffer.
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2014-11-06 16:21:03 -07:00
|
|
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
2017-04-08 14:12:26 -07:00
|
|
|
local command, expect = helpers.command, helpers.expect
|
2020-10-19 11:17:51 -07:00
|
|
|
local poke_eventloop = helpers.poke_eventloop
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
describe('test5', function()
|
|
|
|
setup(clear)
|
|
|
|
|
2017-09-24 11:42:48 -07:00
|
|
|
-- luacheck: ignore 621 (Indentation)
|
2014-11-06 16:21:03 -07:00
|
|
|
it('is working', function()
|
|
|
|
insert([[
|
|
|
|
start of test file Xxx
|
|
|
|
vim: set noai :
|
|
|
|
this is a test
|
|
|
|
this is a test
|
|
|
|
this is a test
|
|
|
|
this is a test
|
|
|
|
end of test file Xxx]])
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
command('w! Xxx0')
|
|
|
|
command('au BufLeave Xxx bwipe')
|
|
|
|
command('/start of')
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
-- Write test file Xxx.
|
2017-04-08 14:12:26 -07:00
|
|
|
command('.,/end of/w! Xxx')
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
-- Split to Xxx.
|
2017-04-08 14:12:26 -07:00
|
|
|
command('sp Xxx')
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
-- Delete buffer Xxx, now we're back here.
|
2017-04-08 14:12:26 -07:00
|
|
|
command('bwipe')
|
2014-11-06 16:21:03 -07:00
|
|
|
feed('G?this is a<cr>')
|
|
|
|
feed('othis is some more text<esc>')
|
2020-10-19 11:17:51 -07:00
|
|
|
poke_eventloop()
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
-- Append some text to this file.
|
|
|
|
|
|
|
|
-- Write current file contents.
|
2017-04-08 14:12:26 -07:00
|
|
|
command('?start?,$yank A')
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
-- Delete current buffer, get an empty one.
|
2017-04-08 14:12:26 -07:00
|
|
|
command('bwipe!')
|
2015-03-10 22:47:38 -07:00
|
|
|
-- Append an extra line to the output register.
|
2014-11-06 16:21:03 -07:00
|
|
|
feed('ithis is another test line<esc>:yank A<cr>')
|
2020-10-19 11:17:51 -07:00
|
|
|
poke_eventloop()
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
-- Output results
|
2017-04-08 14:12:26 -07:00
|
|
|
command('%d')
|
|
|
|
command('0put a')
|
|
|
|
command('$d')
|
2014-11-06 16:21:03 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
|
|
|
start of test file Xxx
|
|
|
|
vim: set noai :
|
|
|
|
this is a test
|
|
|
|
this is a test
|
|
|
|
this is a test
|
|
|
|
this is a test
|
|
|
|
this is some more text
|
|
|
|
end of test file Xxx
|
|
|
|
this is another test line]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
teardown(function()
|
|
|
|
os.remove('Xxx')
|
|
|
|
os.remove('Xxx0')
|
|
|
|
end)
|
|
|
|
end)
|