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')
|
2019-01-30 11:52:50 -07:00
|
|
|
local feed_data = thelpers.feed_data
|
2015-11-17 14:44:00 -07:00
|
|
|
local feed, clear = helpers.feed, helpers.clear
|
2020-10-19 11:17:51 -07:00
|
|
|
local poke_eventloop = helpers.poke_eventloop
|
2018-04-28 16:39:21 -07:00
|
|
|
local command = helpers.command
|
|
|
|
local retry = helpers.retry
|
|
|
|
local eq = helpers.eq
|
|
|
|
local eval = helpers.eval
|
2022-11-13 06:52:19 -07:00
|
|
|
local skip = helpers.skip
|
2022-11-21 17:13:30 -07:00
|
|
|
local is_os = helpers.is_os
|
2015-03-25 05:14:47 -07:00
|
|
|
|
2018-04-28 16:39:21 -07:00
|
|
|
describe(':terminal window', function()
|
2015-03-25 05:14:47 -07:00
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = thelpers.screen_setup()
|
|
|
|
end)
|
|
|
|
|
2018-04-28 16:39:21 -07:00
|
|
|
it('sets topline correctly #8556', function()
|
2022-11-21 17:13:30 -07:00
|
|
|
skip(is_os('win'))
|
2018-04-28 16:39:21 -07:00
|
|
|
-- Test has hardcoded assumptions of dimensions.
|
|
|
|
eq(7, eval('&lines'))
|
2019-01-30 11:52:50 -07:00
|
|
|
feed_data('\n\n\n') -- Add blank lines.
|
2018-04-28 16:39:21 -07:00
|
|
|
-- Terminal/shell contents must exceed the height of this window.
|
|
|
|
command('topleft 1split')
|
2019-01-30 11:52:50 -07:00
|
|
|
eq('terminal', eval('&buftype'))
|
2018-04-28 16:39:21 -07:00
|
|
|
feed([[i<cr>]])
|
|
|
|
-- Check topline _while_ in terminal-mode.
|
|
|
|
retry(nil, nil, function()
|
|
|
|
eq(6, eval('winsaveview()["topline"]'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2017-10-28 08:54:29 -07:00
|
|
|
describe("with 'number'", function()
|
|
|
|
it('wraps text', function()
|
|
|
|
feed([[<C-\><C-N>]])
|
|
|
|
feed([[:set numberwidth=1 number<CR>i]])
|
2017-10-25 08:18:47 -07:00
|
|
|
screen:expect([[
|
2017-10-28 08:54:29 -07:00
|
|
|
{7:1 }tty ready |
|
|
|
|
{7:2 }rows: 6, cols: 48 |
|
|
|
|
{7:3 }{1: } |
|
|
|
|
{7:4 } |
|
|
|
|
{7:5 } |
|
|
|
|
{7:6 } |
|
2017-10-25 08:18:47 -07:00
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
2023-10-02 19:23:03 -07:00
|
|
|
feed_data('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
2017-10-25 08:18:47 -07:00
|
|
|
screen:expect([[
|
2017-10-28 08:54:29 -07:00
|
|
|
{7:1 }tty ready |
|
|
|
|
{7:2 }rows: 6, cols: 48 |
|
|
|
|
{7:3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV|
|
|
|
|
{7:4 }WXYZ{1: } |
|
|
|
|
{7:5 } |
|
|
|
|
{7:6 } |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
|
|
|
|
-- numberwidth=9
|
|
|
|
feed([[<C-\><C-N>]])
|
|
|
|
feed([[:set numberwidth=9 number<CR>i]])
|
2017-11-12 12:22:35 -07:00
|
|
|
screen:expect([[
|
|
|
|
{7: 1 }tty ready |
|
|
|
|
{7: 2 }rows: 6, cols: 48 |
|
|
|
|
{7: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO|
|
2023-05-24 01:04:49 -07:00
|
|
|
{7: 4 }PQRSTUVWXYZrows: 6, cols: 41 |
|
2017-11-12 12:22:35 -07:00
|
|
|
{7: 5 }{1: } |
|
|
|
|
{7: 6 } |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
2023-10-02 19:23:03 -07:00
|
|
|
feed_data(' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
2017-10-28 08:54:29 -07:00
|
|
|
screen:expect([[
|
|
|
|
{7: 1 }tty ready |
|
|
|
|
{7: 2 }rows: 6, cols: 48 |
|
|
|
|
{7: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO|
|
2023-05-24 01:04:49 -07:00
|
|
|
{7: 4 }PQRSTUVWXYZrows: 6, cols: 41 |
|
2017-11-12 12:22:35 -07:00
|
|
|
{7: 5 } abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN|
|
|
|
|
{7: 6 }OPQRSTUVWXYZ{1: } |
|
2017-10-25 08:18:47 -07:00
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2023-10-02 19:23:03 -07:00
|
|
|
describe("with 'statuscolumn'", function()
|
|
|
|
it('wraps text', function()
|
|
|
|
command([[set number statuscolumn=++%l\ \ ]])
|
|
|
|
screen:expect([[
|
|
|
|
{7:++1 }tty ready |
|
|
|
|
{7:++2 }rows: 6, cols: 45 |
|
|
|
|
{7:++3 }{1: } |
|
|
|
|
{7:++4 } |
|
|
|
|
{7:++5 } |
|
|
|
|
{7:++6 } |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
feed_data('\n\n\n\n\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
|
|
|
screen:expect([[
|
|
|
|
{7:++4 } |
|
|
|
|
{7:++5 } |
|
|
|
|
{7:++6 } |
|
|
|
|
{7:++7 } |
|
|
|
|
{7:++8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS|
|
|
|
|
{7:++9 }TUVWXYZ{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
feed_data('\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
|
|
|
screen:expect([[
|
|
|
|
{7:++7 } |
|
|
|
|
{7:++8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR|
|
|
|
|
{7:++9 }STUVWXYZ |
|
|
|
|
{7:++10 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR|
|
|
|
|
{7:++11 }STUVWXYZrows: 6, cols: 44 |
|
|
|
|
{7:++12 }{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2017-10-28 08:54:29 -07:00
|
|
|
describe("with 'colorcolumn'", function()
|
2015-03-25 05:14:47 -07:00
|
|
|
before_each(function()
|
2017-10-28 08:54:29 -07:00
|
|
|
feed([[<C-\><C-N>]])
|
2015-05-10 03:47:31 -07:00
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
2017-02-26 19:10:55 -07:00
|
|
|
{2:^ } |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*5
|
2015-05-10 03:47:31 -07:00
|
|
|
]])
|
2017-10-28 08:54:29 -07:00
|
|
|
feed(':set colorcolumn=20<CR>i')
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('wont show the color column', function()
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
{1: } |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*4
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with fold set', function()
|
|
|
|
before_each(function()
|
2017-10-28 08:54:29 -07:00
|
|
|
feed([[<C-\><C-N>:set foldenable foldmethod=manual<CR>i]])
|
2019-01-30 11:52:50 -07:00
|
|
|
feed_data({ 'line1', 'line2', 'line3', 'line4', '' })
|
2015-03-25 05:14:47 -07:00
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('wont show any folds', function()
|
2017-10-28 08:54:29 -07:00
|
|
|
feed([[<C-\><C-N>ggvGzf]])
|
2020-10-19 11:17:51 -07:00
|
|
|
poke_eventloop()
|
2015-03-25 05:14:47 -07:00
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
{2: } |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2018-04-28 16:39:21 -07:00
|
|
|
describe(':terminal with multigrid', function()
|
2019-01-25 10:44:29 -07:00
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2023-12-06 16:15:37 -07:00
|
|
|
screen = thelpers.screen_setup(0, nil, 50, nil, { ext_multigrid = true })
|
2019-01-25 10:44:29 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('resizes to requested size', function()
|
|
|
|
screen:expect([[
|
|
|
|
## grid 1
|
2023-12-09 05:42:00 -07:00
|
|
|
[2:--------------------------------------------------]|*6
|
2019-09-01 02:25:00 -07:00
|
|
|
[3:--------------------------------------------------]|
|
2019-01-25 10:44:29 -07:00
|
|
|
## grid 2
|
|
|
|
tty ready |
|
|
|
|
{1: } |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*4
|
2019-09-01 02:25:00 -07:00
|
|
|
## grid 3
|
|
|
|
{3:-- TERMINAL --} |
|
2019-01-25 10:44:29 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
screen:try_resize_grid(2, 20, 10)
|
2022-11-21 17:13:30 -07:00
|
|
|
if is_os('win') then
|
2019-01-25 10:44:29 -07:00
|
|
|
screen:expect { any = 'rows: 10, cols: 20' }
|
|
|
|
else
|
|
|
|
screen:expect([[
|
|
|
|
## grid 1
|
2023-12-09 05:42:00 -07:00
|
|
|
[2:--------------------------------------------------]|*6
|
2019-09-01 02:25:00 -07:00
|
|
|
[3:--------------------------------------------------]|
|
2019-01-25 10:44:29 -07:00
|
|
|
## grid 2
|
|
|
|
tty ready |
|
|
|
|
rows: 10, cols: 20 |
|
|
|
|
{1: } |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*7
|
2019-09-01 02:25:00 -07:00
|
|
|
## grid 3
|
|
|
|
{3:-- TERMINAL --} |
|
2019-01-25 10:44:29 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
screen:try_resize_grid(2, 70, 3)
|
2022-11-21 17:13:30 -07:00
|
|
|
if is_os('win') then
|
2019-01-25 10:44:29 -07:00
|
|
|
screen:expect { any = 'rows: 3, cols: 70' }
|
|
|
|
else
|
|
|
|
screen:expect([[
|
|
|
|
## grid 1
|
2023-12-09 05:42:00 -07:00
|
|
|
[2:--------------------------------------------------]|*6
|
2019-09-01 02:25:00 -07:00
|
|
|
[3:--------------------------------------------------]|
|
2019-01-25 10:44:29 -07:00
|
|
|
## grid 2
|
|
|
|
rows: 10, cols: 20 |
|
|
|
|
rows: 3, cols: 70 |
|
|
|
|
{1: } |
|
2019-09-01 02:25:00 -07:00
|
|
|
## grid 3
|
|
|
|
{3:-- TERMINAL --} |
|
2019-01-25 10:44:29 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
screen:try_resize_grid(2, 0, 0)
|
2022-11-21 17:13:30 -07:00
|
|
|
if is_os('win') then
|
2019-01-25 10:44:29 -07:00
|
|
|
screen:expect { any = 'rows: 6, cols: 50' }
|
|
|
|
else
|
|
|
|
screen:expect([[
|
|
|
|
## grid 1
|
2023-12-09 05:42:00 -07:00
|
|
|
[2:--------------------------------------------------]|*6
|
2019-09-01 02:25:00 -07:00
|
|
|
[3:--------------------------------------------------]|
|
2019-01-25 10:44:29 -07:00
|
|
|
## grid 2
|
|
|
|
tty ready |
|
|
|
|
rows: 10, cols: 20 |
|
|
|
|
rows: 3, cols: 70 |
|
|
|
|
rows: 6, cols: 50 |
|
|
|
|
{1: } |
|
|
|
|
|
|
2019-09-01 02:25:00 -07:00
|
|
|
## grid 3
|
|
|
|
{3:-- TERMINAL --} |
|
2019-01-25 10:44:29 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|