diff options
Diffstat (limited to 'test/functional/terminal/edit_spec.lua')
-rw-r--r-- | test/functional/terminal/edit_spec.lua | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua index c98aef70b1..84d7ae6e9c 100644 --- a/test/functional/terminal/edit_spec.lua +++ b/test/functional/terminal/edit_spec.lua @@ -12,7 +12,7 @@ local eq = helpers.eq describe(':edit term://*', function() local get_screen = function(columns, lines) local scr = screen.new(columns, lines) - scr:attach(false) + scr:attach({rgb=false}) return scr end @@ -31,45 +31,39 @@ describe(':edit term://*', function() eq(termopen_runs[1], termopen_runs[1]:match('^term://.//%d+:$')) end) - it('runs TermOpen early enough to respect terminal_scrollback_buffer_size', function() + it("runs TermOpen early enough to set buffer-local 'scrollback'", 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() + command('set shellxquote=') -- win: avoid extra quotes + local rep_size = rep:byte() -- 'a' => 97 local sb = 10 - local gsb = 20 - meths.set_var('terminal_scrollback_buffer_size', gsb) - command('autocmd TermOpen * :let b:terminal_scrollback_buffer_size = ' - .. tostring(sb)) + command('autocmd TermOpen * :setlocal scrollback='..tostring(sb) + ..'|call feedkeys("G", "n")') command('edit term://foobar') + local bufcontents = {} local winheight = curwinmeths.get_height() - -- I have no idea why there is + 4 needed. But otherwise it works fine with - -- different scrollbacks. - local shift = -4 - local buf_cont_start = rep_size - 1 - sb - winheight - shift - local bufline = function(i) return ('%d: foobar'):format(i) end + local buf_cont_start = rep_size - sb - winheight + 2 for i = buf_cont_start,(rep_size - 1) do - bufcontents[#bufcontents + 1] = bufline(i) + bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i) end bufcontents[#bufcontents + 1] = '' bufcontents[#bufcontents + 1] = '[Process exited 0]' - -- 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 - for i = 0,(winheight - 1) do - local line = bufline(buf_cont_start + i - 1) + for i = 1,(winheight - 1) do + local line = bufcontents[#bufcontents - winheight + i] exp_screen = (exp_screen - .. (did_cursor and '' or '^') .. line .. (' '):rep(columns - #line) .. '|\n') - did_cursor = true end - exp_screen = exp_screen .. (' '):rep(columns) .. '|\n' + exp_screen = exp_screen..'^[Process exited 0] |\n' + + exp_screen = exp_screen..(' '):rep(columns)..'|\n' scr:expect(exp_screen) - eq(bufcontents, curbufmeths.get_lines(1, -1, true)) + eq(bufcontents, curbufmeths.get_lines(0, -1, true)) end) end) |