diff options
-rw-r--r-- | test/functional/terminal/edit_spec.lua | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua index 1062bb4843..3ad1b33970 100644 --- a/test/functional/terminal/edit_spec.lua +++ b/test/functional/terminal/edit_spec.lua @@ -10,6 +10,12 @@ local clear = helpers.clear local eq = helpers.eq describe(':edit term://*', function() + local get_screen = function(columns, lines) + local scr = screen.new(columns, lines) + scr:attach(false) + return scr + end + before_each(function() clear() meths.set_option('shell', nvim_dir .. '/shell-test') @@ -26,6 +32,8 @@ describe(':edit term://*', function() end) it('runs TermOpen early enough to respect terminal_scrollback_buffer_size', function() + local columns, lines = 20, 4 + local scr = get_screen(columns, lines) local rep = 'a' meths.set_option('shellcmdflag', 'REP ' .. rep) local rep_size = rep:byte() @@ -40,12 +48,29 @@ describe(':edit term://*', function() -- I have no idea why there is + 4 needed. But otherwise it works fine with -- different scrollbacks. local shift = -4 - for i = (rep_size - 1 - sb - winheight - shift),(rep_size - 1) do - bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i) + local buf_cont_start = rep_size - 1 - sb - winheight - shift + local bufline = function(i) return ('%d: foobar'):format(i) end + for i = buf_cont_start,(rep_size - 1) do + bufcontents[#bufcontents + 1] = bufline(i) end bufcontents[#bufcontents + 1] = '' bufcontents[#bufcontents + 1] = '[Process exited 0]' - command('sleep 500m') + -- Do not ask me why displayed screen is one line *before* buffer + -- contents: buffer starts with 87:, screen with 86:. + local exp_screen = '\n' + local did_cursor = false + local shift = 10 + for i = 0,(winheight - 1) do + local line = bufline(buf_cont_start + i - 1) + exp_screen = (exp_screen + .. (did_cursor and '' or '^') + .. line + .. (' '):rep(columns - #line) + .. '|\n') + did_cursor = true + end + exp_screen = exp_screen .. (' '):rep(columns) .. '|\n' + scr:expect(exp_screen) eq(bufcontents, curbufmeths.get_line_slice(1, -1, true, true)) end) end) |