robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1018 B39 linesraw
1-- Some tests for buffer-local autocommands
2
3local n = require('test.functional.testnvim')()
4local t = require('test.testutil')
5
6local describe, it, setup, teardown = t.describe, t.it, t.setup, t.teardown
7local clear = n.clear
8local expect = n.expect
9local command = n.command
10
11local fname = 'Xtest-functional-legacy-054'
12
13describe('BufLeave <buffer>', function()
14  setup(clear)
15
16  it('is working', function()
17    command('write! ' .. fname)
18    command('autocmd BufLeave <buffer> normal! Ibuffer-local autocommand')
19    command('autocmd BufLeave <buffer> update')
20
21    -- Here, autocommand for xx shall append a line
22    -- But autocommand shall not apply to buffer named <buffer>
23    command('edit somefile')
24
25    -- Here, autocommand shall be auto-deleted
26    command('bwipeout ' .. fname)
27
28    -- Nothing shall be written
29    command('edit ' .. fname)
30    command('edit somefile')
31    command('edit ' .. fname)
32
33    expect('buffer-local autocommand')
34  end)
35
36  teardown(function()
37    os.remove(fname)
38  end)
39end)