2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-03-25 05:14:47 -07:00
|
|
|
local thelpers = require('test.functional.terminal.helpers')
|
2015-11-17 14:44:00 -07:00
|
|
|
local clear = helpers.clear
|
2015-03-25 05:14:47 -07:00
|
|
|
local feed, nvim = helpers.feed, helpers.nvim
|
2017-04-08 14:12:26 -07:00
|
|
|
local feed_command = helpers.feed_command
|
2017-11-12 18:06:32 -07:00
|
|
|
local command = helpers.command
|
|
|
|
local eq = helpers.eq
|
|
|
|
local eval = helpers.eval
|
2018-10-31 16:11:12 -07:00
|
|
|
local iswin = helpers.iswin
|
2018-11-04 05:09:50 -07:00
|
|
|
local retry = helpers.retry
|
2015-03-25 05:14:47 -07:00
|
|
|
|
2018-04-28 16:39:21 -07:00
|
|
|
describe(':terminal', function()
|
2015-03-25 05:14:47 -07:00
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
-- set the statusline to a constant value because of variables like pid
|
|
|
|
-- and current directory and to improve visibility of splits
|
|
|
|
nvim('set_option', 'statusline', '==========')
|
|
|
|
nvim('command', 'highlight StatusLine cterm=NONE')
|
|
|
|
nvim('command', 'highlight StatusLineNC cterm=NONE')
|
|
|
|
nvim('command', 'highlight VertSplit cterm=NONE')
|
|
|
|
screen = thelpers.screen_setup(3)
|
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
2017-11-12 18:06:32 -07:00
|
|
|
it('next to a closing window', function()
|
|
|
|
command('split')
|
|
|
|
command('terminal')
|
|
|
|
command('vsplit foo')
|
|
|
|
eq(3, eval("winnr('$')"))
|
|
|
|
feed('ZQ') -- Close split, should not crash. #7538
|
|
|
|
eq(2, eval("1+1")) -- Still alive?
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('does not change size on WinEnter', function()
|
2017-08-07 17:26:25 -07:00
|
|
|
if helpers.pending_win32(pending) then return end
|
2016-06-20 11:47:23 -07:00
|
|
|
feed('<c-\\><c-n>')
|
2019-03-09 15:12:33 -07:00
|
|
|
feed('k')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('2split')
|
2016-06-20 11:47:23 -07:00
|
|
|
screen:expect([[
|
2019-03-09 15:12:33 -07:00
|
|
|
^tty ready |
|
|
|
|
rows: 5, cols: 50 |
|
2016-06-20 11:47:23 -07:00
|
|
|
========== |
|
|
|
|
tty ready |
|
|
|
|
rows: 5, cols: 50 |
|
|
|
|
{2: } |
|
2017-11-12 18:06:32 -07:00
|
|
|
|
|
|
|
|
|
|
2016-06-20 11:47:23 -07:00
|
|
|
========== |
|
2017-11-12 18:06:32 -07:00
|
|
|
:2split |
|
2016-06-20 11:47:23 -07:00
|
|
|
]])
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('wincmd p')
|
2016-06-20 11:47:23 -07:00
|
|
|
screen:expect([[
|
2017-11-12 18:06:32 -07:00
|
|
|
tty ready |
|
|
|
|
rows: 5, cols: 50 |
|
2016-06-20 11:47:23 -07:00
|
|
|
========== |
|
2019-03-09 15:12:33 -07:00
|
|
|
^tty ready |
|
|
|
|
rows: 5, cols: 50 |
|
2016-06-20 11:47:23 -07:00
|
|
|
{2: } |
|
2017-11-12 18:06:32 -07:00
|
|
|
|
|
|
|
|
|
|
2016-06-20 11:47:23 -07:00
|
|
|
========== |
|
|
|
|
:wincmd p |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2017-11-12 18:06:32 -07:00
|
|
|
it('forwards resize request to the program', function()
|
2018-11-10 03:12:04 -07:00
|
|
|
feed([[<C-\><C-N>G:]]) -- Go to cmdline-mode, so cursor is at bottom.
|
2018-11-04 23:59:14 -07:00
|
|
|
local w1, h1 = screen._width - 3, screen._height - 2
|
|
|
|
local w2, h2 = w1 - 6, h1 - 3
|
2018-10-31 16:11:12 -07:00
|
|
|
|
|
|
|
if iswin() then
|
2018-11-04 23:59:14 -07:00
|
|
|
-- win: SIGWINCH is unreliable, use a weaker test. #7506
|
2018-11-04 19:25:36 -07:00
|
|
|
retry(3, 30000, function()
|
2018-11-04 23:59:14 -07:00
|
|
|
screen:try_resize(w1, h1)
|
2018-11-04 05:09:50 -07:00
|
|
|
screen:expect{any='rows: 7, cols: 47'}
|
2018-11-04 23:59:14 -07:00
|
|
|
screen:try_resize(w2, h2)
|
2018-11-04 05:09:50 -07:00
|
|
|
screen:expect{any='rows: 4, cols: 41'}
|
|
|
|
end)
|
2018-10-31 16:11:12 -07:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-11-04 23:59:14 -07:00
|
|
|
screen:try_resize(w1, h1)
|
2017-11-12 18:06:32 -07:00
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
rows: 7, cols: 47 |
|
|
|
|
{2: } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:^ |
|
|
|
|
]])
|
2018-11-04 23:59:14 -07:00
|
|
|
screen:try_resize(w2, h2)
|
2017-11-12 18:06:32 -07:00
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
rows: 7, cols: 47 |
|
|
|
|
rows: 4, cols: 41 |
|
|
|
|
{2: } |
|
|
|
|
:^ |
|
|
|
|
]])
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
end)
|