2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
|
2024-09-15 03:28:14 -07:00
|
|
|
local tt = require('test.functional.testterm')
|
2024-04-20 08:44:13 -07:00
|
|
|
local clear, eq, api = n.clear, t.eq, n.api
|
|
|
|
local feed = n.feed
|
2024-04-08 02:03:20 -07:00
|
|
|
local feed_data = tt.feed_data
|
|
|
|
local enter_altscreen = tt.enter_altscreen
|
|
|
|
local exit_altscreen = tt.exit_altscreen
|
2015-03-25 05:14:47 -07:00
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
if t.skip(t.is_os('win')) then
|
2024-01-02 18:09:18 -07:00
|
|
|
return
|
|
|
|
end
|
2016-08-15 16:42:12 -07:00
|
|
|
|
2018-04-28 16:39:21 -07:00
|
|
|
describe(':terminal altscreen', function()
|
2015-03-25 05:14:47 -07:00
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2024-09-15 03:28:14 -07:00
|
|
|
screen = tt.setup_screen()
|
2024-01-02 18:09:18 -07:00
|
|
|
feed_data({
|
|
|
|
'line1',
|
|
|
|
'line2',
|
|
|
|
'line3',
|
|
|
|
'line4',
|
|
|
|
'line5',
|
|
|
|
'line6',
|
|
|
|
'line7',
|
|
|
|
'line8',
|
|
|
|
'',
|
|
|
|
})
|
2015-03-25 05:14:47 -07:00
|
|
|
screen:expect([[
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
line6 |
|
|
|
|
line7 |
|
|
|
|
line8 |
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
enter_altscreen()
|
|
|
|
screen:expect([[
|
2023-12-09 05:42:00 -07:00
|
|
|
|*5
|
2015-03-25 05:14:47 -07:00
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
2024-01-12 10:59:57 -07:00
|
|
|
eq(10, api.nvim_buf_line_count(0))
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('wont clear lines already in the scrollback', function()
|
|
|
|
feed('<c-\\><c-n>gg')
|
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*3
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('on exit', function()
|
|
|
|
before_each(exit_altscreen)
|
|
|
|
|
|
|
|
it('restores buffer state', function()
|
|
|
|
screen:expect([[
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
line6 |
|
|
|
|
line7 |
|
|
|
|
line8 |
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
feed('<c-\\><c-n>gg')
|
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with lines printed after the screen height limit', function()
|
|
|
|
before_each(function()
|
2024-01-02 18:09:18 -07:00
|
|
|
feed_data({
|
|
|
|
'line9',
|
|
|
|
'line10',
|
|
|
|
'line11',
|
|
|
|
'line12',
|
|
|
|
'line13',
|
|
|
|
'line14',
|
|
|
|
'line15',
|
|
|
|
'line16',
|
|
|
|
'',
|
|
|
|
})
|
2015-03-25 05:14:47 -07:00
|
|
|
screen:expect([[
|
|
|
|
line12 |
|
|
|
|
line13 |
|
|
|
|
line14 |
|
|
|
|
line15 |
|
|
|
|
line16 |
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('wont modify line count', function()
|
2024-01-12 10:59:57 -07:00
|
|
|
eq(10, api.nvim_buf_line_count(0))
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('wont modify lines in the scrollback', function()
|
|
|
|
feed('<c-\\><c-n>gg')
|
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line12 |
|
|
|
|
line13 |
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('after height is decreased by 2', function()
|
|
|
|
local function wait_removal()
|
|
|
|
screen:try_resize(screen._width, screen._height - 2)
|
|
|
|
screen:expect([[
|
2023-12-09 05:42:00 -07:00
|
|
|
|*2
|
2015-03-25 05:14:47 -07:00
|
|
|
rows: 4, cols: 50 |
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
it('removes 2 lines from the bottom of the visible buffer', function()
|
|
|
|
wait_removal()
|
|
|
|
feed('<c-\\><c-n>4k')
|
|
|
|
screen:expect([[
|
2022-02-09 00:46:37 -07:00
|
|
|
^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*2
|
2015-03-25 05:14:47 -07:00
|
|
|
rows: 4, cols: 50 |
|
|
|
|
|
|
|
|
|
]])
|
2024-01-12 10:59:57 -07:00
|
|
|
eq(9, api.nvim_buf_line_count(0))
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
describe('and after exit', function()
|
|
|
|
before_each(function()
|
|
|
|
wait_removal()
|
|
|
|
exit_altscreen()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('restore buffer state', function()
|
|
|
|
screen:expect([[
|
|
|
|
line5 |
|
|
|
|
line6 |
|
|
|
|
line7 |
|
2022-02-09 00:46:37 -07:00
|
|
|
line8 |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|