2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
local tt = require('test.functional.terminal.testutil')
|
|
|
|
local feed_data = tt.feed_data
|
2024-04-20 08:44:13 -07:00
|
|
|
local feed, clear = n.feed, n.clear
|
|
|
|
local poke_eventloop = n.poke_eventloop
|
|
|
|
local command = n.command
|
2024-04-08 02:03:20 -07:00
|
|
|
local retry = t.retry
|
|
|
|
local eq = t.eq
|
2024-04-20 08:44:13 -07:00
|
|
|
local eval = n.eval
|
2024-04-08 02:03:20 -07:00
|
|
|
local skip = t.skip
|
|
|
|
local is_os = t.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()
|
2024-04-08 02:03:20 -07:00
|
|
|
screen = tt.screen_setup()
|
2015-03-25 05:14:47 -07:00
|
|
|
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()
|
2024-02-28 10:47:47 -07:00
|
|
|
skip(is_os('win')) -- todo(clason): unskip when reenabling reflow
|
2017-10-28 08:54:29 -07:00
|
|
|
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|
|
2024-02-28 10:47:47 -07:00
|
|
|
{7: 4 }WXYZrows: 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|
|
2024-02-28 10:47:47 -07:00
|
|
|
{7: 4 }WXYZrows: 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()
|
2024-02-28 10:47:47 -07:00
|
|
|
skip(is_os('win')) -- todo(clason): unskip when reenabling reflow
|
2023-10-02 19:23:03 -07:00
|
|
|
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|
|
2024-02-28 10:47:47 -07:00
|
|
|
{7:++9 }TUVWXYZ |
|
2023-10-02 19:23:03 -07:00
|
|
|
{7:++10 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR|
|
2024-02-28 10:47:47 -07:00
|
|
|
{7:++11 }TUVWXYZrows: 6, cols: 44 |
|
2023-10-02 19:23:03 -07:00
|
|
|
{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()
|
2024-04-08 02:03:20 -07:00
|
|
|
screen = tt.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)
|