1
local helpers = require('test.functional.helpers')
2
local screen = require('test.functional.ui.screen')
4
local curbufmeths = helpers.curbufmeths
5
local curwinmeths = helpers.curwinmeths
6
local nvim_dir = helpers.nvim_dir
7
local command = helpers.command
8
local meths = helpers.meths
9
local clear = helpers.clear
12
describe(':edit term://*', function()
13
local get_screen = function(columns, lines)
14
local scr = screen.new(columns, lines)
19
before_each(function()
21
meths.set_option('shell', nvim_dir .. '/shell-test')
22
meths.set_option('shellcmdflag', 'EXE')
25
it('runs TermOpen event', function()
26
meths.set_var('termopen_runs', {})
27
command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))')
28
command('edit term://')
29
local termopen_runs = meths.get_var('termopen_runs')
31
eq(termopen_runs[1], termopen_runs[1]:match('^term://.//%d+:$'))
34
it('runs TermOpen early enough to respect terminal_scrollback_buffer_size', function()
35
local columns, lines = 20, 4
36
local scr = get_screen(columns, lines)
38
meths.set_option('shellcmdflag', 'REP ' .. rep)
39
local rep_size = rep:byte()
42
meths.set_var('terminal_scrollback_buffer_size', gsb)
43
command('autocmd TermOpen * :let b:terminal_scrollback_buffer_size = '
45
command('edit term://foobar')
46
local bufcontents = {}
47
local winheight = curwinmeths.get_height()
48
-- I have no idea why there is + 4 needed. But otherwise it works fine with
49
-- different scrollbacks.
51
local buf_cont_start = rep_size - 1 - sb - winheight - shift
52
local bufline = function(i) return ('%d: foobar'):format(i) end
53
for i = buf_cont_start,(rep_size - 1) do
54
bufcontents[#bufcontents + 1] = bufline(i)
56
bufcontents[#bufcontents + 1] = ''
57
bufcontents[#bufcontents + 1] = '[Process exited 0]'
58
-- Do not ask me why displayed screen is one line *before* buffer
59
-- contents: buffer starts with 87:, screen with 86:.
60
local exp_screen = '\n'
61
local did_cursor = false
62
for i = 0,(winheight - 1) do
63
local line = bufline(buf_cont_start + i - 1)
64
exp_screen = (exp_screen
65
.. (did_cursor and '' or '^')
67
.. (' '):rep(columns - #line)
71
exp_screen = exp_screen .. (' '):rep(columns) .. '|\n'
72
scr:expect(exp_screen)
73
eq(bufcontents, curbufmeths.get_lines(1, -1, true))