From 3259e45f926bcde4052e8b989e039f6047c2b205 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 13 Mar 2019 22:13:25 +0100 Subject: autocmd: rename: "++nested", "++once" Based on feedback from upstream: https://github.com/vim/vim/pull/4100 --- test/functional/autocmd/autocmd_spec.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index 4efabd37fb..f666f9cf75 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -59,9 +59,9 @@ describe('autocmd', function() end) end) - it('-once', function() -- :help autocmd-once + it('++once', function() -- :help autocmd-once -- - -- ":autocmd ... -once" executes its handler once, then removes the handler. + -- ":autocmd ... ++once" executes its handler once, then removes the handler. -- local expected = { 'Many1', @@ -76,10 +76,10 @@ describe('autocmd', function() } command('let g:foo = []') command('autocmd TabNew * :call add(g:foo, "Many1")') - command('autocmd TabNew * -once :call add(g:foo, "Once1")') - command('autocmd TabNew * -once :call add(g:foo, "Once2")') + command('autocmd TabNew * ++once :call add(g:foo, "Once1")') + command('autocmd TabNew * ++once :call add(g:foo, "Once2")') command('autocmd TabNew * :call add(g:foo, "Many2")') - command('autocmd TabNew * -once :call add(g:foo, "Once3")') + command('autocmd TabNew * ++once :call add(g:foo, "Once3")') eq(dedent([[ --- Autocommands --- @@ -103,25 +103,25 @@ describe('autocmd', function() funcs.execute('autocmd Tabnew')) -- - -- ":autocmd ... -once" handlers can be deleted. + -- ":autocmd ... ++once" handlers can be deleted. -- expected = {} command('let g:foo = []') - command('autocmd TabNew * -once :call add(g:foo, "Once1")') + command('autocmd TabNew * ++once :call add(g:foo, "Once1")') command('autocmd! TabNew') command('tabnew') eq(expected, eval('g:foo')) -- - -- ":autocmd ... -once -nested" + -- ":autocmd ... ++once ++nested" -- expected = { 'OptionSet-Once', 'CursorMoved-Once', } command('let g:foo = []') - command('autocmd OptionSet binary -nested -once :call add(g:foo, "OptionSet-Once")') - command('autocmd CursorMoved -once -nested setlocal binary|:call add(g:foo, "CursorMoved-Once")') + command('autocmd OptionSet binary ++nested ++once :call add(g:foo, "OptionSet-Once")') + command('autocmd CursorMoved ++once ++nested setlocal binary|:call add(g:foo, "CursorMoved-Once")') command("put ='foo bar baz'") feed('0llhlh') eq(expected, eval('g:foo')) -- cgit From b1f25ea18797101f423cab23ac52c4e17377c5d4 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 13 Mar 2019 22:31:07 +0100 Subject: 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. --- test/functional/autocmd/autocmd_spec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index f666f9cf75..814624d8e2 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -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) -- cgit