1
1
local helpers = require('test.functional.helpers')
2
local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
4
describe('TabNew', function()
6
describe('au TabNew', function()
7
describe('with * as <afile>', function()
8
it('matches when opening any new tab', function()
9
nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")')
10
eq("\ntabnew:2:1", nvim('command_output', 'tabnew'))
11
eq("\ntabnew:3:2\n\"test.x\" [New File]", nvim('command_output', 'tabnew test.x'))
14
describe('with FILE as <afile>', function()
15
it('matches when opening a new tab for FILE', function()
16
local tmp_path = nvim('eval', 'tempname()')
17
nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
18
eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
3
local clear = helpers.clear
4
local command = helpers.command
6
local eval = helpers.eval
8
describe('autocmd TabNew', function()
11
it('matches when opening any new tab', function()
12
command('autocmd! TabNew * let g:test = "tabnew:".tabpagenr().":".bufnr("")')
14
eq('tabnew:2:1', eval('g:test'))
15
command('tabnew test.x')
16
eq('tabnew:3:2', eval('g:test'))
19
it('matches when opening a new tab for FILE', function()
20
local tmp_path = helpers.funcs.tempname()
21
command('let g:test = "foo"')
22
command('autocmd! TabNew ' .. tmp_path .. ' let g:test = "bar"')
23
command('tabnew ' .. tmp_path ..'X')
24
eq('foo', eval('g:test'))
25
command('tabnew ' .. tmp_path)
26
eq('bar', eval('g:test'))