diff options
Diffstat (limited to 'test/functional/terminal/edit_spec.lua')
-rw-r--r-- | test/functional/terminal/edit_spec.lua | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua index 29361bc0fa..f7ceb0a68b 100644 --- a/test/functional/terminal/edit_spec.lua +++ b/test/functional/terminal/edit_spec.lua @@ -1,72 +1,68 @@ local helpers = require('test.functional.helpers')(after_each) local screen = require('test.functional.ui.screen') -local curbufmeths = helpers.curbufmeths -local curwinmeths = helpers.curwinmeths local testprg = helpers.testprg local command = helpers.command -local funcs = helpers.funcs -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local clear = helpers.clear local eq = helpers.eq local matches = helpers.matches -local pesc = helpers.pesc +local pesc = vim.pesc describe(':edit term://*', function() local get_screen = function(columns, lines) local scr = screen.new(columns, lines) - scr:attach({rgb=false}) + scr:attach({ rgb = false }) return scr end before_each(function() clear() - meths.set_option_value('shell', testprg('shell-test'), {}) - meths.set_option_value('shellcmdflag', 'EXE', {}) + api.nvim_set_option_value('shell', testprg('shell-test'), {}) + api.nvim_set_option_value('shellcmdflag', 'EXE', {}) end) it('runs TermOpen event', function() - meths.set_var('termopen_runs', {}) + api.nvim_set_var('termopen_runs', {}) command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))') command('edit term://') - local termopen_runs = meths.get_var('termopen_runs') + local termopen_runs = api.nvim_get_var('termopen_runs') eq(1, #termopen_runs) - local cwd = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') - matches('^term://'..pesc(cwd)..'//%d+:$', termopen_runs[1]) + local cwd = fn.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') + matches('^term://' .. pesc(cwd) .. '//%d+:$', termopen_runs[1]) end) it("runs TermOpen early enough to set buffer-local 'scrollback'", function() local columns, lines = 20, 4 local scr = get_screen(columns, lines) local rep = 97 - meths.set_option_value('shellcmdflag', 'REP ' .. rep, {}) - command('set shellxquote=') -- win: avoid extra quotes + api.nvim_set_option_value('shellcmdflag', 'REP ' .. rep, {}) + command('set shellxquote=') -- win: avoid extra quotes local sb = 10 - command('autocmd TermOpen * :setlocal scrollback='..tostring(sb) - ..'|call feedkeys("G", "n")') + command( + 'autocmd TermOpen * :setlocal scrollback=' .. tostring(sb) .. '|call feedkeys("G", "n")' + ) command('edit term://foobar') local bufcontents = {} - local winheight = curwinmeths.get_height() + local winheight = api.nvim_win_get_height(0) local buf_cont_start = rep - sb - winheight + 2 - for i = buf_cont_start,(rep - 1) do + for i = buf_cont_start, (rep - 1) do bufcontents[#bufcontents + 1] = ('%d: foobar'):format(i) end bufcontents[#bufcontents + 1] = '' bufcontents[#bufcontents + 1] = '[Process exited 0]' local exp_screen = '\n' - for i = 1,(winheight - 1) do + for i = 1, (winheight - 1) do local line = bufcontents[#bufcontents - winheight + i] - exp_screen = (exp_screen - .. line - .. (' '):rep(columns - #line) - .. '|\n') + exp_screen = (exp_screen .. line .. (' '):rep(columns - #line) .. '|\n') end - exp_screen = exp_screen..'^[Process exited 0] |\n' + exp_screen = exp_screen .. '^[Process exited 0] |\n' - exp_screen = exp_screen..(' '):rep(columns)..'|\n' + exp_screen = exp_screen .. (' '):rep(columns) .. '|\n' scr:expect(exp_screen) - eq(bufcontents, curbufmeths.get_lines(0, -1, true)) + eq(bufcontents, api.nvim_buf_get_lines(0, 0, -1, true)) end) end) |