aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/scrollback_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal/scrollback_spec.lua')
-rw-r--r--test/functional/terminal/scrollback_spec.lua90
1 files changed, 62 insertions, 28 deletions
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 05f81295c2..c665e64a80 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command
+local iswin = helpers.iswin
local eval = helpers.eval
local command = helpers.command
local wait = helpers.wait
@@ -11,8 +12,6 @@ local curbufmeths = helpers.curbufmeths
local nvim = helpers.nvim
local feed_data = thelpers.feed_data
-if helpers.pending_win32(pending) then return end
-
describe('terminal scrollback', function()
local screen
@@ -58,7 +57,7 @@ describe('terminal scrollback', function()
end)
end)
- describe('with the cursor at the last row', function()
+ describe('with cursor at last row', function()
before_each(function()
feed_data({'line1', 'line2', 'line3', 'line4', ''})
screen:expect([[
@@ -139,16 +138,18 @@ describe('terminal scrollback', function()
end)
- describe('and the height is decreased by 1', function()
+ describe('and height decreased by 1', function()
+ if helpers.pending_win32(pending) then return end
local function will_hide_top_line()
- screen:try_resize(screen._width, screen._height - 1)
+ feed([[<C-\><C-N>:]]) -- Go to cmdline-mode, so cursor is at bottom.
+ screen:try_resize(screen._width - 2, screen._height - 1)
screen:expect([[
- line2 |
- line3 |
- line4 |
- rows: 5, cols: 30 |
- {1: } |
- {3:-- TERMINAL --} |
+ line2 |
+ line3 |
+ line4 |
+ rows: 5, cols: 28 |
+ {2: } |
+ :^ |
]])
end
@@ -157,23 +158,23 @@ describe('terminal scrollback', function()
describe('and then decreased by 2', function()
before_each(function()
will_hide_top_line()
- screen:try_resize(screen._width, screen._height - 2)
+ screen:try_resize(screen._width - 2, screen._height - 2)
end)
it('will hide the top 3 lines', function()
screen:expect([[
- rows: 5, cols: 30 |
- rows: 3, cols: 30 |
- {1: } |
- {3:-- TERMINAL --} |
+ rows: 5, cols: 28 |
+ rows: 3, cols: 26 |
+ {2: } |
+ :^ |
]])
eq(8, curbuf('line_count'))
- feed('<c-\\><c-n>3k')
+ feed([[<C-\><C-N>3k]])
screen:expect([[
- ^line4 |
- rows: 5, cols: 30 |
- rows: 3, cols: 30 |
- |
+ ^line4 |
+ rows: 5, cols: 28 |
+ rows: 3, cols: 26 |
+ |
]])
end)
end)
@@ -181,6 +182,11 @@ describe('terminal scrollback', function()
end)
describe('with empty lines after the cursor', function()
+ -- 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
+
describe('and the height is decreased by 2', function()
before_each(function()
screen:try_resize(screen._width, screen._height - 2)
@@ -255,6 +261,10 @@ describe('terminal scrollback', function()
end)
describe('and the height is increased by 1', function()
+ -- 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
local function pop_then_push()
screen:try_resize(screen._width, screen._height + 1)
screen:expect([[
@@ -384,10 +394,20 @@ describe("'scrollback' option", function()
end
it('set to 0 behaves as 1', function()
- local screen = thelpers.screen_setup(nil, "['sh']", 30)
+ 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
curbufmeths.set_option('scrollback', 0)
- feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
+ 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
screen:expect('line30 ', nil, nil, nil, true)
retry(nil, nil, function() expect_lines(7) end)
@@ -395,7 +415,13 @@ describe("'scrollback' option", function()
end)
it('deletes lines (only) if necessary', function()
- local screen = thelpers.screen_setup(nil, "['sh']", 30)
+ 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
curbufmeths.set_option('scrollback', 200)
@@ -403,7 +429,11 @@ describe("'scrollback' option", function()
screen:expect('$', nil, nil, nil, true)
wait()
- feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
+ 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
screen:expect('line30 ', nil, nil, nil, true)
@@ -416,7 +446,11 @@ describe("'scrollback' option", function()
-- Terminal job data is received asynchronously, may happen before the
-- 'scrollback' option is synchronized with the internal sb_buffer.
command('sleep 100m')
- feed_data('for i in $(seq 1 40); do echo "line$i"; done\n')
+ 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
screen:expect('line40 ', nil, nil, nil, true)
@@ -428,10 +462,10 @@ describe("'scrollback' option", function()
screen:detach()
end)
- it('defaults to 1000 in terminal buffers', function()
+ it('defaults to 10000 in terminal buffers', function()
set_fake_shell()
command('terminal')
- eq(1000, curbufmeths.get_option('scrollback'))
+ eq(10000, curbufmeths.get_option('scrollback'))
end)
it('error if set to invalid value', function()