aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd/tabclose_spec.lua
diff options
context:
space:
mode:
authorFelipe Morales <hel.sheep@gmail.com>2015-01-05 01:03:22 -0300
committerJustin M. Keyes <justinkz@gmail.com>2015-02-16 23:24:31 -0500
commit3ffc5d81c34cfdd535573a50790690c88e4324bb (patch)
treeaa35b1fcb2e89f4f11976edb4e32b315f746e168 /test/functional/autocmd/tabclose_spec.lua
parent66d94869a0f01902d93597eae4244f9a64db82fc (diff)
downloadrneovim-3ffc5d81c34cfdd535573a50790690c88e4324bb.tar.gz
rneovim-3ffc5d81c34cfdd535573a50790690c88e4324bb.tar.bz2
rneovim-3ffc5d81c34cfdd535573a50790690c88e4324bb.zip
Add TabClosed event
TabClosed is triggered when a tab page closes.
Diffstat (limited to 'test/functional/autocmd/tabclose_spec.lua')
-rw-r--r--test/functional/autocmd/tabclose_spec.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/functional/autocmd/tabclose_spec.lua b/test/functional/autocmd/tabclose_spec.lua
new file mode 100644
index 0000000000..847362e3de
--- /dev/null
+++ b/test/functional/autocmd/tabclose_spec.lua
@@ -0,0 +1,36 @@
+local helpers = require('test.functional.helpers')
+local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
+ helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
+ helpers.eq, helpers.neq, helpers.ok
+
+describe('TabClosed', function()
+ describe('au TabClosed', function()
+ describe('with * as <afile>', function()
+ it('matches when closing any tab', function()
+ clear()
+ nvim('command', 'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()')
+ repeat
+ nvim('command', 'tabnew')
+ until nvim('eval', 'tabpagenr()') == 6 -- current tab is now 6
+ eq("\ntabclosed:6:6:5", nvim('command_output', 'tabclose')) -- close last 6, current tab is now 5
+ eq("\ntabclosed:5:5:4", nvim('command_output', 'close')) -- close last window on tab, closes tab
+ eq("\ntabclosed:2:2:3", nvim('command_output', '2tabclose')) -- close tab 2, current tab is now 3
+ eq("\ntabclosed:1:1:2\ntabclosed:1:1:1", nvim('command_output', 'tabonly')) -- close tabs 1 and 2
+ end)
+ end)
+ describe('with NR as <afile>', function()
+ it('matches when closing a tab whose index is NR', function()
+ tmp_path = nvim('eval', 'tempname()')
+ nvim('command', 'au! TabClosed 2 echom "tabclosed:match"')
+ repeat
+ nvim('command', 'tabnew')
+ until nvim('eval', 'tabpagenr()') == 5 -- current tab is now 5
+ -- sanity check, we shouldn't match on tabs with numbers other than 2
+ eq("\ntabclosed:5:5:4", nvim('command_output', 'tabclose'))
+ -- close tab page 2, current tab is now 3
+ eq("\ntabclosed:2:2:3\ntabclosed:match", nvim('command_output', '2tabclose'))
+ end)
+ end)
+ end)
+end)
+