mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
autocmd: do not show empty section after ++once handlers expire
Problem: If autocmd pattern only contained `++once` handlers, and
all of them completed, then there would be an empty group
displayed by `:autocmd Foo`.
Solution: Delete the pattern if all of its commands were deleted.
This commit is contained in:
@@ -125,5 +125,23 @@ describe('autocmd', function()
|
||||
command("put ='foo bar baz'")
|
||||
feed('0llhlh')
|
||||
eq(expected, eval('g:foo'))
|
||||
|
||||
--
|
||||
-- :autocmd should not show empty section after ++once handlers expire.
|
||||
--
|
||||
expected = {
|
||||
'Once1',
|
||||
'Once2',
|
||||
}
|
||||
command('let g:foo = []')
|
||||
command('autocmd! TabNew') -- Clear all TabNew handlers.
|
||||
command('autocmd TabNew * ++once :call add(g:foo, "Once1")')
|
||||
command('autocmd TabNew * ++once :call add(g:foo, "Once2")')
|
||||
command('tabnew')
|
||||
eq(expected, eval('g:foo'))
|
||||
eq(dedent([[
|
||||
|
||||
--- Autocommands ---]]),
|
||||
funcs.execute('autocmd Tabnew'))
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user