2015-03-25 05:14:47 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
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')
|
|
|
|
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
|
2017-04-08 14:12:26 -07:00
|
|
|
local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command
|
2017-04-02 02:32:23 -07:00
|
|
|
local iswin = helpers.iswin
|
2017-02-21 07:16:48 -07:00
|
|
|
local eval = helpers.eval
|
|
|
|
local command = helpers.command
|
2015-03-25 05:14:47 -07:00
|
|
|
local wait = helpers.wait
|
2017-02-21 07:16:48 -07:00
|
|
|
local retry = helpers.retry
|
|
|
|
local curbufmeths = helpers.curbufmeths
|
2017-03-24 12:21:05 -07:00
|
|
|
local nvim = helpers.nvim
|
2015-03-25 05:14:47 -07:00
|
|
|
local feed_data = thelpers.feed_data
|
|
|
|
|
|
|
|
describe('terminal scrollback', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2017-02-22 08:10:10 -07:00
|
|
|
screen = thelpers.screen_setup(nil, nil, 30)
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
2017-02-21 07:16:48 -07:00
|
|
|
describe('when the limit is exceeded', function()
|
2015-03-25 05:14:47 -07:00
|
|
|
before_each(function()
|
|
|
|
local lines = {}
|
|
|
|
for i = 1, 30 do
|
|
|
|
table.insert(lines, 'line'..tostring(i))
|
|
|
|
end
|
|
|
|
table.insert(lines, '')
|
|
|
|
feed_data(lines)
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line26 |
|
|
|
|
line27 |
|
|
|
|
line28 |
|
|
|
|
line29 |
|
|
|
|
line30 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('will delete extra lines at the top', function()
|
|
|
|
feed('<c-\\><c-n>gg')
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
^line16 |
|
|
|
|
line17 |
|
|
|
|
line18 |
|
|
|
|
line19 |
|
|
|
|
line20 |
|
|
|
|
line21 |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2017-08-13 10:54:48 -07:00
|
|
|
describe('with cursor at last row', function()
|
2015-03-25 05:14:47 -07:00
|
|
|
before_each(function()
|
|
|
|
feed_data({'line1', 'line2', 'line3', 'line4', ''})
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('and 1 line is printed', function()
|
|
|
|
before_each(function() feed_data({'line5', ''}) end)
|
|
|
|
|
|
|
|
it('will hide the top line', function()
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
eq(7, curbuf('line_count'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('and then 3 more lines are printed', function()
|
|
|
|
before_each(function() feed_data({'line6', 'line7', 'line8'}) end)
|
|
|
|
|
|
|
|
it('will hide the top 4 lines', function()
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
line6 |
|
|
|
|
line7 |
|
|
|
|
line8{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
feed('<c-\\><c-n>6k')
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
^line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
line6 |
|
|
|
|
line7 |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
feed('gg')
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
^tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
feed('G')
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
line6 |
|
|
|
|
line7 |
|
|
|
|
^line8{2: } |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
2017-08-13 10:54:48 -07:00
|
|
|
describe('and height decreased by 1', function()
|
2015-03-25 05:14:47 -07:00
|
|
|
local function will_hide_top_line()
|
2017-08-13 10:54:48 -07:00
|
|
|
feed([[<C-\><C-N>:]]) -- Go to cmdline-mode, so cursor is at bottom.
|
|
|
|
screen:try_resize(screen._width - 2, screen._height - 1)
|
2017-08-06 05:26:17 -07:00
|
|
|
screen:expect([[
|
2017-08-13 10:54:48 -07:00
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
rows: 5, cols: 28 |
|
|
|
|
{2: } |
|
|
|
|
:^ |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
it('will hide top line', will_hide_top_line)
|
|
|
|
|
|
|
|
describe('and then decreased by 2', function()
|
|
|
|
before_each(function()
|
|
|
|
will_hide_top_line()
|
2017-08-13 10:54:48 -07:00
|
|
|
screen:try_resize(screen._width - 2, screen._height - 2)
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('will hide the top 3 lines', function()
|
2017-08-06 05:26:17 -07:00
|
|
|
screen:expect([[
|
2017-08-13 10:54:48 -07:00
|
|
|
rows: 5, cols: 28 |
|
|
|
|
rows: 3, cols: 26 |
|
|
|
|
{2: } |
|
|
|
|
:^ |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
eq(8, curbuf('line_count'))
|
2017-08-13 10:54:48 -07:00
|
|
|
feed([[<C-\><C-N>3k]])
|
2015-03-25 05:14:47 -07:00
|
|
|
screen:expect([[
|
2017-08-13 10:54:48 -07:00
|
|
|
^line4 |
|
|
|
|
rows: 5, cols: 28 |
|
|
|
|
rows: 3, cols: 26 |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with empty lines after the cursor', function()
|
2017-08-06 15:26:43 -07:00
|
|
|
-- XXX: Can't test this reliably on Windows unless the cursor is _moved_
|
|
|
|
-- by the resize. http://docs.libuv.org/en/v1.x/signal.html
|
|
|
|
-- See also: https://github.com/rprichard/winpty/issues/110
|
2017-08-06 05:26:17 -07:00
|
|
|
if helpers.pending_win32(pending) then return end
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
describe('and the height is decreased by 2', function()
|
|
|
|
before_each(function()
|
|
|
|
screen:try_resize(screen._width, screen._height - 2)
|
|
|
|
end)
|
|
|
|
|
|
|
|
local function will_delete_last_two_lines()
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
tty ready |
|
|
|
|
rows: 4, cols: 30 |
|
|
|
|
{1: } |
|
|
|
|
|
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
eq(4, curbuf('line_count'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it('will delete the last two empty lines', will_delete_last_two_lines)
|
|
|
|
|
|
|
|
describe('and then decreased by 1', function()
|
|
|
|
before_each(function()
|
|
|
|
will_delete_last_two_lines()
|
|
|
|
screen:try_resize(screen._width, screen._height - 1)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('will delete the last line and hide the first', function()
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
rows: 4, cols: 30 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
eq(4, curbuf('line_count'))
|
|
|
|
feed('<c-\\><c-n>gg')
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
^tty ready |
|
|
|
|
rows: 4, cols: 30 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
feed('a')
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
rows: 4, cols: 30 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with 4 lines hidden in the scrollback', function()
|
|
|
|
before_each(function()
|
|
|
|
feed_data({'line1', 'line2', 'line3', 'line4', ''})
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
screen:try_resize(screen._width, screen._height - 3)
|
2017-08-06 05:26:17 -07:00
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line4 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
eq(7, curbuf('line_count'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('and the height is increased by 1', function()
|
2017-08-06 15:26:43 -07:00
|
|
|
-- XXX: Can't test this reliably on Windows unless the cursor is _moved_
|
|
|
|
-- by the resize. http://docs.libuv.org/en/v1.x/signal.html
|
|
|
|
-- See also: https://github.com/rprichard/winpty/issues/110
|
|
|
|
if helpers.pending_win32(pending) then return end
|
2015-03-25 05:14:47 -07:00
|
|
|
local function pop_then_push()
|
|
|
|
screen:try_resize(screen._width, screen._height + 1)
|
2017-08-06 05:26:17 -07:00
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line4 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
rows: 4, cols: 30 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
it('will pop 1 line and then push it back', pop_then_push)
|
|
|
|
|
|
|
|
describe('and then by 3', function()
|
|
|
|
before_each(function()
|
|
|
|
pop_then_push()
|
|
|
|
eq(8, curbuf('line_count'))
|
|
|
|
screen:try_resize(screen._width, screen._height + 3)
|
|
|
|
end)
|
|
|
|
|
|
|
|
local function pop3_then_push1()
|
2017-08-06 05:26:17 -07:00
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
rows: 4, cols: 30 |
|
|
|
|
rows: 7, cols: 30 |
|
|
|
|
{1: } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
eq(9, curbuf('line_count'))
|
|
|
|
feed('<c-\\><c-n>gg')
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
^tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
rows: 4, cols: 30 |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
|
|
|
it('will pop 3 lines and then push one back', pop3_then_push1)
|
|
|
|
|
|
|
|
describe('and then by 4', function()
|
|
|
|
before_each(function()
|
|
|
|
pop3_then_push1()
|
|
|
|
feed('Gi')
|
|
|
|
screen:try_resize(screen._width, screen._height + 4)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('will show all lines and leave a blank one at the end', function()
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
tty ready |
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
rows: 3, cols: 30 |
|
|
|
|
rows: 4, cols: 30 |
|
|
|
|
rows: 7, cols: 30 |
|
|
|
|
rows: 11, cols: 30 |
|
|
|
|
{1: } |
|
|
|
|
|
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
-- since there's an empty line after the cursor, the buffer line
|
|
|
|
-- count equals the terminal screen height
|
|
|
|
eq(11, curbuf('line_count'))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('terminal prints more lines than the screen height and exits', function()
|
|
|
|
it('will push extra lines to scrollback', function()
|
|
|
|
clear()
|
2017-02-22 08:10:10 -07:00
|
|
|
local screen = Screen.new(30, 7)
|
2016-06-08 02:26:06 -07:00
|
|
|
screen:attach({rgb=false})
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert')
|
2015-03-25 05:14:47 -07:00
|
|
|
wait()
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
line6 |
|
|
|
|
line7 |
|
|
|
|
line8 |
|
|
|
|
line9 |
|
|
|
|
|
|
|
|
|
[Process exited 0] |
|
|
|
|
-- TERMINAL -- |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
2015-08-21 19:53:48 -07:00
|
|
|
feed('<cr>')
|
|
|
|
-- closes the buffer correctly after pressing a key
|
|
|
|
screen:expect([[
|
2017-02-22 08:10:10 -07:00
|
|
|
^ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
~ |
|
|
|
|
|
|
2015-08-21 19:53:48 -07:00
|
|
|
]])
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2017-02-21 07:16:48 -07:00
|
|
|
describe("'scrollback' option", function()
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
end)
|
|
|
|
|
2017-03-24 12:21:05 -07:00
|
|
|
local function set_fake_shell()
|
|
|
|
-- shell-test.c is a fake shell that prints its arguments and exits.
|
|
|
|
nvim('set_option', 'shell', nvim_dir..'/shell-test')
|
|
|
|
nvim('set_option', 'shellcmdflag', 'EXE')
|
|
|
|
end
|
|
|
|
|
2017-03-11 06:46:35 -07:00
|
|
|
local function expect_lines(expected, epsilon)
|
|
|
|
local ep = epsilon and epsilon or 0
|
2017-02-21 07:16:48 -07:00
|
|
|
local actual = eval("line('$')")
|
2017-03-11 06:46:35 -07:00
|
|
|
if expected > actual + ep and expected < actual - ep then
|
|
|
|
error('expected (+/- '..ep..'): '..expected..', actual: '..tostring(actual))
|
2017-02-21 07:16:48 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it('set to 0 behaves as 1', function()
|
2017-03-28 02:07:58 -07:00
|
|
|
local screen
|
|
|
|
if iswin() then
|
|
|
|
screen = thelpers.screen_setup(nil,
|
|
|
|
"['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30)
|
|
|
|
else
|
|
|
|
screen = thelpers.screen_setup(nil, "['sh']", 30)
|
|
|
|
end
|
2017-02-21 07:16:48 -07:00
|
|
|
|
|
|
|
curbufmeths.set_option('scrollback', 0)
|
2017-03-28 02:07:58 -07:00
|
|
|
if iswin() then
|
|
|
|
feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r')
|
|
|
|
else
|
|
|
|
feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
|
|
|
|
end
|
2017-02-21 07:16:48 -07:00
|
|
|
screen:expect('line30 ', nil, nil, nil, true)
|
|
|
|
retry(nil, nil, function() expect_lines(7) end)
|
|
|
|
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('deletes lines (only) if necessary', function()
|
2017-03-28 02:07:58 -07:00
|
|
|
local screen
|
|
|
|
if iswin() then
|
|
|
|
screen = thelpers.screen_setup(nil,
|
|
|
|
"['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30)
|
|
|
|
else
|
|
|
|
screen = thelpers.screen_setup(nil, "['sh']", 30)
|
|
|
|
end
|
2017-02-21 07:16:48 -07:00
|
|
|
|
|
|
|
curbufmeths.set_option('scrollback', 200)
|
|
|
|
|
|
|
|
-- Wait for prompt.
|
|
|
|
screen:expect('$', nil, nil, nil, true)
|
|
|
|
|
|
|
|
wait()
|
2017-03-28 02:07:58 -07:00
|
|
|
if iswin() then
|
|
|
|
feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r')
|
|
|
|
else
|
|
|
|
feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
|
|
|
|
end
|
2017-02-21 07:16:48 -07:00
|
|
|
|
|
|
|
screen:expect('line30 ', nil, nil, nil, true)
|
|
|
|
|
2017-03-11 06:46:35 -07:00
|
|
|
retry(nil, nil, function() expect_lines(33, 2) end)
|
2017-02-21 07:16:48 -07:00
|
|
|
curbufmeths.set_option('scrollback', 10)
|
|
|
|
wait()
|
|
|
|
retry(nil, nil, function() expect_lines(16) end)
|
|
|
|
curbufmeths.set_option('scrollback', 10000)
|
2017-03-11 06:46:35 -07:00
|
|
|
retry(nil, nil, function() expect_lines(16) end)
|
2017-02-21 07:16:48 -07:00
|
|
|
-- Terminal job data is received asynchronously, may happen before the
|
|
|
|
-- 'scrollback' option is synchronized with the internal sb_buffer.
|
|
|
|
command('sleep 100m')
|
2017-03-28 02:07:58 -07:00
|
|
|
if iswin() then
|
|
|
|
feed_data('for($i=1;$i -le 40;$i++){Write-Host \"line$i\"}\r')
|
|
|
|
else
|
|
|
|
feed_data('for i in $(seq 1 40); do echo "line$i"; done\n')
|
|
|
|
end
|
2017-02-21 07:16:48 -07:00
|
|
|
|
|
|
|
screen:expect('line40 ', nil, nil, nil, true)
|
|
|
|
|
|
|
|
retry(nil, nil, function() expect_lines(58) end)
|
|
|
|
-- Verify off-screen state
|
|
|
|
eq('line35', eval("getline(line('w0') - 1)"))
|
|
|
|
eq('line26', eval("getline(line('w0') - 10)"))
|
|
|
|
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
2017-03-24 12:21:05 -07:00
|
|
|
it('defaults to 1000 in terminal buffers', function()
|
|
|
|
set_fake_shell()
|
|
|
|
command('terminal')
|
2017-02-21 07:16:48 -07:00
|
|
|
eq(1000, curbufmeths.get_option('scrollback'))
|
|
|
|
end)
|
|
|
|
|
2017-03-24 12:21:05 -07:00
|
|
|
it('error if set to invalid value', function()
|
2017-02-21 07:16:48 -07:00
|
|
|
local status, rv = pcall(command, 'set scrollback=-2')
|
|
|
|
eq(false, status) -- assert failure
|
|
|
|
eq('E474:', string.match(rv, "E%d*:"))
|
|
|
|
|
|
|
|
status, rv = pcall(command, 'set scrollback=100001')
|
|
|
|
eq(false, status) -- assert failure
|
|
|
|
eq('E474:', string.match(rv, "E%d*:"))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('defaults to -1 on normal buffers', function()
|
2017-03-24 12:21:05 -07:00
|
|
|
command('new')
|
2017-02-21 07:16:48 -07:00
|
|
|
eq(-1, curbufmeths.get_option('scrollback'))
|
|
|
|
end)
|
|
|
|
|
2017-03-24 12:21:05 -07:00
|
|
|
it(':setlocal in a normal buffer is an error', function()
|
2017-02-21 07:16:48 -07:00
|
|
|
command('new')
|
2017-04-20 03:32:14 -07:00
|
|
|
|
|
|
|
-- :setlocal to -1 is NOT an error.
|
|
|
|
feed_command('setlocal scrollback=-1')
|
|
|
|
eq(nil, string.match(eval("v:errmsg"), "E%d*:"))
|
|
|
|
feed('<CR>')
|
|
|
|
|
|
|
|
-- :setlocal to anything except -1 is an error.
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('setlocal scrollback=42')
|
2017-02-21 07:16:48 -07:00
|
|
|
feed('<CR>')
|
|
|
|
eq('E474:', string.match(eval("v:errmsg"), "E%d*:"))
|
2017-03-24 12:21:05 -07:00
|
|
|
eq(-1, curbufmeths.get_option('scrollback'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it(':set updates local value and global default', function()
|
|
|
|
set_fake_shell()
|
|
|
|
command('set scrollback=42') -- set global and (attempt) local
|
|
|
|
eq(-1, curbufmeths.get_option('scrollback')) -- normal buffer: -1
|
|
|
|
command('terminal')
|
|
|
|
eq(42, curbufmeths.get_option('scrollback')) -- inherits global default
|
|
|
|
command('setlocal scrollback=99')
|
|
|
|
eq(99, curbufmeths.get_option('scrollback'))
|
|
|
|
command('set scrollback<') -- reset to global default
|
|
|
|
eq(42, curbufmeths.get_option('scrollback'))
|
|
|
|
command('setglobal scrollback=734') -- new global default
|
|
|
|
eq(42, curbufmeths.get_option('scrollback')) -- local value did not change
|
|
|
|
command('terminal')
|
|
|
|
eq(734, curbufmeths.get_option('scrollback'))
|
2017-02-21 07:16:48 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
end)
|