diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-03-15 12:38:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-15 12:38:53 +0100 |
commit | 1baf4edbd97539a7d331e350d23de35eeabf68b6 (patch) | |
tree | 42ab813ad2cb35113519a371a976adfacd82518a /test | |
parent | 680252aa15159f0e969f6d169d01a8fbad097fa4 (diff) | |
parent | b1f25ea18797101f423cab23ac52c4e17377c5d4 (diff) | |
download | rneovim-1baf4edbd97539a7d331e350d23de35eeabf68b6.tar.gz rneovim-1baf4edbd97539a7d331e350d23de35eeabf68b6.tar.bz2 rneovim-1baf4edbd97539a7d331e350d23de35eeabf68b6.zip |
Merge #9728 from justinmk/autocmd-once
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/autocmd/autocmd_spec.lua | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index 4efabd37fb..814624d8e2 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,27 +103,45 @@ 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 ... <buffer> -once -nested" + -- ":autocmd ... <buffer> ++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 <buffer> -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 <buffer> ++once ++nested setlocal binary|:call add(g:foo, "CursorMoved-Once")') 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) |