From 85be914879d49435c3b689efd5f1dae70e81d168 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 30 Nov 2023 10:55:21 +0800 Subject: test: unskip more terminal tests on Windows (#26315) --- test/functional/terminal/scrollback_spec.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 1e278e4cff..d687dff230 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -600,21 +600,24 @@ describe("pending scrollback line handling", function() assert_alive() end) - it("does not crash after nvim_buf_call #14891", function() - skip(is_os('win')) - exec_lua [[ + it('does not crash after nvim_buf_call #14891', function() + exec_lua([[ local bufnr = vim.api.nvim_create_buf(false, true) + local args = ... vim.api.nvim_buf_call(bufnr, function() - vim.fn.termopen({"echo", ("hi\n"):rep(11)}) + vim.fn.termopen(args) end) vim.api.nvim_win_set_buf(0, bufnr) - vim.cmd("startinsert") - ]] + vim.cmd('startinsert') + ]], is_os('win') + and {'cmd.exe', '/c', 'for /L %I in (1,1,12) do @echo hi'} + or {'printf', ('hi\n'):rep(12)} + ) screen:expect [[ hi | hi | hi | - | + hi | | [Process exited 0]{2: } | {3:-- TERMINAL --} | -- cgit From 6b00b8a369480a6535e7d286dd6ea27a6b0c94a5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 7 Dec 2023 07:15:37 +0800 Subject: test(terminal): remove unnecessary string operations (#26434) --- test/functional/terminal/scrollback_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index d687dff230..c882d51f34 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -392,9 +392,9 @@ describe("'scrollback' option", function() it('set to 0 behaves as 1', function() local screen if is_os('win') then - screen = thelpers.screen_setup(nil, "['cmd.exe']", 30) + screen = thelpers.screen_setup(nil, { 'cmd.exe' }, 30) else - screen = thelpers.screen_setup(nil, "['sh']", 30) + screen = thelpers.screen_setup(nil, { 'sh' }, 30) end meths.set_option_value('scrollback', 0, {}) @@ -407,10 +407,10 @@ describe("'scrollback' option", function() local screen if is_os('win') then command([[let $PROMPT='$$']]) - screen = thelpers.screen_setup(nil, "['cmd.exe']", 30) + screen = thelpers.screen_setup(nil, { 'cmd.exe' }, 30) else command('let $PS1 = "$"') - screen = thelpers.screen_setup(nil, "['sh']", 30) + screen = thelpers.screen_setup(nil, { 'sh' }, 30) end meths.set_option_value('scrollback', 200, {}) -- cgit From 1037ce2e461034a20e35ad59969fd05d5ad68b91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Dec 2023 20:42:00 +0800 Subject: test: avoid repeated screen lines in expected states This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g --- test/functional/terminal/scrollback_spec.lua | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index c882d51f34..d2c636b03f 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -362,11 +362,7 @@ describe(':terminal prints more lines than the screen height and exits', functio -- closes the buffer correctly after pressing a key screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 | ]]) end) @@ -614,10 +610,7 @@ describe("pending scrollback line handling", function() or {'printf', ('hi\n'):rep(12)} ) screen:expect [[ - hi | - hi | - hi | - hi | + hi |*4 | [Process exited 0]{2: } | {3:-- TERMINAL --} | -- cgit From 619407eb548c7df56bc99b945338e9446f846fbb Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 14 Dec 2023 16:08:00 +0800 Subject: feat(nvim_open_term): convert LF => CRLF (#26384) Problem: Unlike termopen(), nvim_open_term() PTYs do not carriage-return the cursor on newline ("\n") input. nvim --clean :let chan_id = nvim_open_term(1, {}) :call chansend(chan_id, ["here", "are", "some", "lines"]) Actual behavior: here are some lines Expected behaviour: here are some lines Solution: Add `force_crlf` option, and enable it by default. --- test/functional/terminal/scrollback_spec.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index d2c636b03f..00104734ef 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -576,21 +576,21 @@ describe("pending scrollback line handling", function() ]] screen:expect [[ {1: 1 }^a | - {1: 2 } a | - {1: 3 } a | - {1: 4 } a | - {1: 5 } a | - {1: 6 } a | + {1: 2 }a | + {1: 3 }a | + {1: 4 }a | + {1: 5 }a | + {1: 6 }a | | ]] feed('G') screen:expect [[ - {1: 7 } a | - {1: 8 } a | - {1: 9 } a | - {1: 10 } a | - {1: 11 } a | - {1: 12 } ^a | + {1: 7 }a | + {1: 8 }a | + {1: 9 }a | + {1: 10 }a | + {1: 11 }a | + {1: 12 }^a | | ]] assert_alive() -- cgit From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/terminal/scrollback_spec.lua | 102 ++++++++++++++++----------- 1 file changed, 61 insertions(+), 41 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 00104734ef..f5c9887cdd 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -28,7 +28,7 @@ describe(':terminal scrollback', function() before_each(function() local lines = {} for i = 1, 30 do - table.insert(lines, 'line'..tostring(i)) + table.insert(lines, 'line' .. tostring(i)) end table.insert(lines, '') feed_data(lines) @@ -59,7 +59,7 @@ describe(':terminal scrollback', function() describe('with cursor at last row', function() before_each(function() - feed_data({'line1', 'line2', 'line3', 'line4', ''}) + feed_data({ 'line1', 'line2', 'line3', 'line4', '' }) screen:expect([[ tty ready | line1 | @@ -72,7 +72,9 @@ describe(':terminal scrollback', function() end) describe('and 1 line is printed', function() - before_each(function() feed_data({'line5', ''}) end) + before_each(function() + feed_data({ 'line5', '' }) + end) it('will hide the top line', function() screen:expect([[ @@ -88,7 +90,9 @@ describe(':terminal scrollback', function() end) describe('and then 3 more lines are printed', function() - before_each(function() feed_data({'line6', 'line7', 'line8'}) end) + before_each(function() + feed_data({ 'line6', 'line7', 'line8' }) + end) it('will hide the top 4 lines', function() screen:expect([[ @@ -137,7 +141,6 @@ describe(':terminal scrollback', function() end) end) - describe('and height decreased by 1', function() local function will_hide_top_line() feed([[]]) @@ -184,7 +187,9 @@ describe(':terminal scrollback', 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 skip(is_os('win')) then return end + if skip(is_os('win')) then + return + end describe('and the height is decreased by 2', function() before_each(function() @@ -239,7 +244,7 @@ describe(':terminal scrollback', function() describe('with 4 lines hidden in the scrollback', function() before_each(function() - feed_data({'line1', 'line2', 'line3', 'line4', ''}) + feed_data({ 'line1', 'line2', 'line3', 'line4', '' }) screen:expect([[ tty ready | line1 | @@ -263,7 +268,9 @@ describe(':terminal scrollback', 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 skip(is_os('win')) then return end + if skip(is_os('win')) then + return + end local function pop_then_push() screen:try_resize(screen._width, screen._height + 1) screen:expect([[ @@ -347,7 +354,7 @@ describe(':terminal prints more lines than the screen height and exits', functio it('will push extra lines to scrollback', function() clear() local screen = Screen.new(30, 7) - screen:attach({rgb=false}) + screen:attach({ rgb = false }) command(("call termopen(['%s', '10']) | startinsert"):format(testprg('tty-test'))) screen:expect([[ line6 | @@ -381,7 +388,7 @@ describe("'scrollback' option", function() local ep = epsilon and epsilon or 0 local actual = eval("line('$')") if expected > actual + ep and expected < actual - ep then - error('expected (+/- '..ep..'): '..expected..', actual: '..tostring(actual)) + error('expected (+/- ' .. ep .. '): ' .. expected .. ', actual: ' .. tostring(actual)) end end @@ -395,8 +402,10 @@ describe("'scrollback' option", function() meths.set_option_value('scrollback', 0, {}) feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) - screen:expect{any='30: line '} - retry(nil, nil, function() expect_lines(7) end) + screen:expect { any = '30: line ' } + retry(nil, nil, function() + expect_lines(7) + end) end) it('deletes lines (only) if necessary', function() @@ -412,24 +421,31 @@ describe("'scrollback' option", function() meths.set_option_value('scrollback', 200, {}) -- Wait for prompt. - screen:expect{any='%$'} + screen:expect { any = '%$' } feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) - screen:expect{any='30: line '} + screen:expect { any = '30: line ' } - retry(nil, nil, function() expect_lines(33, 2) end) + retry(nil, nil, function() + expect_lines(33, 2) + end) meths.set_option_value('scrollback', 10, {}) poke_eventloop() - retry(nil, nil, function() expect_lines(16) end) + retry(nil, nil, function() + expect_lines(16) + end) meths.set_option_value('scrollback', 10000, {}) - retry(nil, nil, function() expect_lines(16) end) + retry(nil, nil, function() + expect_lines(16) + end) -- Terminal job data is received asynchronously, may happen before the -- 'scrollback' option is synchronized with the internal sb_buffer. command('sleep 100m') feed_data(('%s REP 41 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) if is_os('win') then - screen:expect{grid=[[ + screen:expect { + grid = [[ 37: line | 38: line | 39: line | @@ -437,9 +453,11 @@ describe("'scrollback' option", function() | ${1: } | {3:-- TERMINAL --} | - ]]} + ]], + } else - screen:expect{grid=[[ + screen:expect { + grid = [[ 36: line | 37: line | 38: line | @@ -447,7 +465,8 @@ describe("'scrollback' option", function() 40: line | {MATCH:.*}| {3:-- TERMINAL --} | - ]]} + ]], + } end expect_lines(58) @@ -461,11 +480,11 @@ describe("'scrollback' option", function() local screen = thelpers.screen_setup(nil, nil, 30) local lines = {} for i = 1, 30 do - table.insert(lines, 'line'..tostring(i)) + table.insert(lines, 'line' .. tostring(i)) end table.insert(lines, '') feed_data(lines) - screen:expect([[ + screen:expect([[ line26 | line27 | line28 | @@ -474,7 +493,7 @@ describe("'scrollback' option", function() {1: } | {3:-- TERMINAL --} | ]]) - local term_height = 6 -- Actual terminal screen height, not the scrollback + local term_height = 6 -- Actual terminal screen height, not the scrollback -- Initial local scrollback = meths.get_option_value('scrollback', {}) eq(scrollback + term_height, eval('line("$")')) @@ -491,10 +510,11 @@ describe("'scrollback' option", function() end) it('error if set to invalid value', function() - eq('Vim(set):E474: Invalid argument: scrollback=-2', - pcall_err(command, 'set scrollback=-2')) - eq('Vim(set):E474: Invalid argument: scrollback=100001', - pcall_err(command, 'set scrollback=100001')) + eq('Vim(set):E474: Invalid argument: scrollback=-2', pcall_err(command, 'set scrollback=-2')) + eq( + 'Vim(set):E474: Invalid argument: scrollback=100001', + pcall_err(command, 'set scrollback=100001') + ) end) it('defaults to -1 on normal buffers', function() @@ -512,7 +532,7 @@ describe("'scrollback' option", function() -- _Local_ scrollback=-1 in :terminal forces the _maximum_. command('setlocal scrollback=-1') - retry(nil, nil, function() -- Fixup happens on refresh, not immediately. + retry(nil, nil, function() -- Fixup happens on refresh, not immediately. eq(100000, meths.get_option_value('scrollback', {})) end) @@ -535,23 +555,22 @@ describe("'scrollback' option", function() it(':set updates local value and global default', function() set_fake_shell() - command('set scrollback=42') -- set global value + command('set scrollback=42') -- set global value eq(42, meths.get_option_value('scrollback', {})) command('terminal') eq(42, meths.get_option_value('scrollback', {})) -- inherits global default command('setlocal scrollback=99') eq(99, meths.get_option_value('scrollback', {})) - command('set scrollback<') -- reset to global default + command('set scrollback<') -- reset to global default eq(42, meths.get_option_value('scrollback', {})) - command('setglobal scrollback=734') -- new global default + command('setglobal scrollback=734') -- new global default eq(42, meths.get_option_value('scrollback', {})) -- local value did not change command('terminal') eq(734, meths.get_option_value('scrollback', {})) end) - end) -describe("pending scrollback line handling", function() +describe('pending scrollback line handling', function() local screen before_each(function() @@ -559,9 +578,9 @@ describe("pending scrollback line handling", function() screen = Screen.new(30, 7) screen:attach() screen:set_default_attr_ids { - [1] = {foreground = Screen.colors.Brown}, - [2] = {reverse = true}, - [3] = {bold = true}, + [1] = { foreground = Screen.colors.Brown }, + [2] = { reverse = true }, + [3] = { bold = true }, } end) @@ -597,7 +616,8 @@ describe("pending scrollback line handling", function() end) it('does not crash after nvim_buf_call #14891', function() - exec_lua([[ + exec_lua( + [[ local bufnr = vim.api.nvim_create_buf(false, true) local args = ... vim.api.nvim_buf_call(bufnr, function() @@ -605,9 +625,9 @@ describe("pending scrollback line handling", function() end) vim.api.nvim_win_set_buf(0, bufnr) vim.cmd('startinsert') - ]], is_os('win') - and {'cmd.exe', '/c', 'for /L %I in (1,1,12) do @echo hi'} - or {'printf', ('hi\n'):rep(12)} + ]], + is_os('win') and { 'cmd.exe', '/c', 'for /L %I in (1,1,12) do @echo hi' } + or { 'printf', ('hi\n'):rep(12) } ) screen:expect [[ hi |*4 -- cgit From c30f2e3182e3b50e7c03932027ac55edfc8ada4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 12:44:54 +0000 Subject: test: typing for helpers.meths --- test/functional/terminal/scrollback_spec.lua | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index f5c9887cdd..7c1da6b32b 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -400,7 +400,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, { 'sh' }, 30) end - meths.set_option_value('scrollback', 0, {}) + meths.nvim_set_option_value('scrollback', 0, {}) feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) screen:expect { any = '30: line ' } retry(nil, nil, function() @@ -418,7 +418,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, { 'sh' }, 30) end - meths.set_option_value('scrollback', 200, {}) + meths.nvim_set_option_value('scrollback', 200, {}) -- Wait for prompt. screen:expect { any = '%$' } @@ -429,12 +429,12 @@ describe("'scrollback' option", function() retry(nil, nil, function() expect_lines(33, 2) end) - meths.set_option_value('scrollback', 10, {}) + meths.nvim_set_option_value('scrollback', 10, {}) poke_eventloop() retry(nil, nil, function() expect_lines(16) end) - meths.set_option_value('scrollback', 10000, {}) + meths.nvim_set_option_value('scrollback', 10000, {}) retry(nil, nil, function() expect_lines(16) end) @@ -495,18 +495,18 @@ describe("'scrollback' option", function() ]]) local term_height = 6 -- Actual terminal screen height, not the scrollback -- Initial - local scrollback = meths.get_option_value('scrollback', {}) + local scrollback = meths.nvim_get_option_value('scrollback', {}) eq(scrollback + term_height, eval('line("$")')) -- Reduction scrollback = scrollback - 2 - meths.set_option_value('scrollback', scrollback, {}) + meths.nvim_set_option_value('scrollback', scrollback, {}) eq(scrollback + term_height, eval('line("$")')) end) it('defaults to 10000 in :terminal buffers', function() set_fake_shell() command('terminal') - eq(10000, meths.get_option_value('scrollback', {})) + eq(10000, meths.nvim_get_option_value('scrollback', {})) end) it('error if set to invalid value', function() @@ -519,7 +519,7 @@ describe("'scrollback' option", function() it('defaults to -1 on normal buffers', function() command('new') - eq(-1, meths.get_option_value('scrollback', {})) + eq(-1, meths.nvim_get_option_value('scrollback', {})) end) it(':setlocal in a :terminal buffer', function() @@ -528,45 +528,45 @@ describe("'scrollback' option", function() -- _Global_ scrollback=-1 defaults :terminal to 10_000. command('setglobal scrollback=-1') command('terminal') - eq(10000, meths.get_option_value('scrollback', {})) + eq(10000, meths.nvim_get_option_value('scrollback', {})) -- _Local_ scrollback=-1 in :terminal forces the _maximum_. command('setlocal scrollback=-1') retry(nil, nil, function() -- Fixup happens on refresh, not immediately. - eq(100000, meths.get_option_value('scrollback', {})) + eq(100000, meths.nvim_get_option_value('scrollback', {})) end) -- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605 command('setglobal scrollback=-1') command('autocmd TermOpen * setlocal scrollback=-1') command('terminal') - eq(100000, meths.get_option_value('scrollback', {})) + eq(100000, meths.nvim_get_option_value('scrollback', {})) end) it(':setlocal in a normal buffer', function() command('new') -- :setlocal to -1. command('setlocal scrollback=-1') - eq(-1, meths.get_option_value('scrollback', {})) + eq(-1, meths.nvim_get_option_value('scrollback', {})) -- :setlocal to anything except -1. Currently, this just has no effect. command('setlocal scrollback=42') - eq(42, meths.get_option_value('scrollback', {})) + eq(42, meths.nvim_get_option_value('scrollback', {})) end) it(':set updates local value and global default', function() set_fake_shell() command('set scrollback=42') -- set global value - eq(42, meths.get_option_value('scrollback', {})) + eq(42, meths.nvim_get_option_value('scrollback', {})) command('terminal') - eq(42, meths.get_option_value('scrollback', {})) -- inherits global default + eq(42, meths.nvim_get_option_value('scrollback', {})) -- inherits global default command('setlocal scrollback=99') - eq(99, meths.get_option_value('scrollback', {})) + eq(99, meths.nvim_get_option_value('scrollback', {})) command('set scrollback<') -- reset to global default - eq(42, meths.get_option_value('scrollback', {})) + eq(42, meths.nvim_get_option_value('scrollback', {})) command('setglobal scrollback=734') -- new global default - eq(42, meths.get_option_value('scrollback', {})) -- local value did not change + eq(42, meths.nvim_get_option_value('scrollback', {})) -- local value did not change command('terminal') - eq(734, meths.get_option_value('scrollback', {})) + eq(734, meths.nvim_get_option_value('scrollback', {})) end) end) -- cgit From 4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 13:11:28 +0000 Subject: test: normalise nvim bridge functions - remove helpers.cur*meths - remove helpers.nvim --- test/functional/terminal/scrollback_spec.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 7c1da6b32b..bd58ef0b0a 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -1,14 +1,13 @@ local Screen = require('test.functional.ui.screen') 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 clear, eq = helpers.clear, helpers.eq local feed, testprg = helpers.feed, helpers.testprg local eval = helpers.eval local command = helpers.command local poke_eventloop = helpers.poke_eventloop local retry = helpers.retry local meths = helpers.meths -local nvim = helpers.nvim local feed_data = thelpers.feed_data local pcall_err = helpers.pcall_err local exec_lua = helpers.exec_lua @@ -86,7 +85,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(7, curbuf('line_count')) + eq(7, meths.nvim_buf_line_count(0)) end) describe('and then 3 more lines are printed', function() @@ -170,7 +169,7 @@ describe(':terminal scrollback', function() {2:^ } | | ]]) - eq(8, curbuf('line_count')) + eq(8, meths.nvim_buf_line_count(0)) feed([[3k]]) screen:expect([[ ^line4 | @@ -204,7 +203,7 @@ describe(':terminal scrollback', function() | {3:-- TERMINAL --} | ]]) - eq(4, curbuf('line_count')) + eq(4, meths.nvim_buf_line_count(0)) end it('will delete the last two empty lines', will_delete_last_two_lines) @@ -222,7 +221,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(4, curbuf('line_count')) + eq(4, meths.nvim_buf_line_count(0)) feed('gg') screen:expect([[ ^tty ready | @@ -261,7 +260,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(7, curbuf('line_count')) + eq(7, meths.nvim_buf_line_count(0)) end) describe('and the height is increased by 1', function() @@ -287,7 +286,7 @@ describe(':terminal scrollback', function() describe('and then by 3', function() before_each(function() pop_then_push() - eq(8, curbuf('line_count')) + eq(8, meths.nvim_buf_line_count(0)) screen:try_resize(screen._width, screen._height + 3) end) @@ -302,7 +301,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(9, curbuf('line_count')) + eq(9, meths.nvim_buf_line_count(0)) feed('gg') screen:expect([[ ^tty ready | @@ -342,7 +341,7 @@ describe(':terminal scrollback', function() ]]) -- since there's an empty line after the cursor, the buffer line -- count equals the terminal screen height - eq(11, curbuf('line_count')) + eq(11, meths.nvim_buf_line_count(0)) end) end) end) @@ -381,7 +380,7 @@ describe("'scrollback' option", function() end) local function set_fake_shell() - nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {}) + meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {}) end local function expect_lines(expected, epsilon) -- cgit From 795f896a5772d5e0795f86642bdf90c82efac45c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 17:59:57 +0000 Subject: test: rename (meths, funcs) -> (api, fn) --- test/functional/terminal/scrollback_spec.lua | 58 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'test/functional/terminal/scrollback_spec.lua') diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index bd58ef0b0a..858e23984d 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -7,7 +7,7 @@ local eval = helpers.eval local command = helpers.command local poke_eventloop = helpers.poke_eventloop local retry = helpers.retry -local meths = helpers.meths +local api = helpers.api local feed_data = thelpers.feed_data local pcall_err = helpers.pcall_err local exec_lua = helpers.exec_lua @@ -85,7 +85,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(7, meths.nvim_buf_line_count(0)) + eq(7, api.nvim_buf_line_count(0)) end) describe('and then 3 more lines are printed', function() @@ -169,7 +169,7 @@ describe(':terminal scrollback', function() {2:^ } | | ]]) - eq(8, meths.nvim_buf_line_count(0)) + eq(8, api.nvim_buf_line_count(0)) feed([[3k]]) screen:expect([[ ^line4 | @@ -203,7 +203,7 @@ describe(':terminal scrollback', function() | {3:-- TERMINAL --} | ]]) - eq(4, meths.nvim_buf_line_count(0)) + eq(4, api.nvim_buf_line_count(0)) end it('will delete the last two empty lines', will_delete_last_two_lines) @@ -221,7 +221,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(4, meths.nvim_buf_line_count(0)) + eq(4, api.nvim_buf_line_count(0)) feed('gg') screen:expect([[ ^tty ready | @@ -260,7 +260,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(7, meths.nvim_buf_line_count(0)) + eq(7, api.nvim_buf_line_count(0)) end) describe('and the height is increased by 1', function() @@ -286,7 +286,7 @@ describe(':terminal scrollback', function() describe('and then by 3', function() before_each(function() pop_then_push() - eq(8, meths.nvim_buf_line_count(0)) + eq(8, api.nvim_buf_line_count(0)) screen:try_resize(screen._width, screen._height + 3) end) @@ -301,7 +301,7 @@ describe(':terminal scrollback', function() {1: } | {3:-- TERMINAL --} | ]]) - eq(9, meths.nvim_buf_line_count(0)) + eq(9, api.nvim_buf_line_count(0)) feed('gg') screen:expect([[ ^tty ready | @@ -341,7 +341,7 @@ describe(':terminal scrollback', function() ]]) -- since there's an empty line after the cursor, the buffer line -- count equals the terminal screen height - eq(11, meths.nvim_buf_line_count(0)) + eq(11, api.nvim_buf_line_count(0)) end) end) end) @@ -380,7 +380,7 @@ describe("'scrollback' option", function() end) local function set_fake_shell() - meths.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {}) + api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {}) end local function expect_lines(expected, epsilon) @@ -399,7 +399,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, { 'sh' }, 30) end - meths.nvim_set_option_value('scrollback', 0, {}) + api.nvim_set_option_value('scrollback', 0, {}) feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n')) screen:expect { any = '30: line ' } retry(nil, nil, function() @@ -417,7 +417,7 @@ describe("'scrollback' option", function() screen = thelpers.screen_setup(nil, { 'sh' }, 30) end - meths.nvim_set_option_value('scrollback', 200, {}) + api.nvim_set_option_value('scrollback', 200, {}) -- Wait for prompt. screen:expect { any = '%$' } @@ -428,12 +428,12 @@ describe("'scrollback' option", function() retry(nil, nil, function() expect_lines(33, 2) end) - meths.nvim_set_option_value('scrollback', 10, {}) + api.nvim_set_option_value('scrollback', 10, {}) poke_eventloop() retry(nil, nil, function() expect_lines(16) end) - meths.nvim_set_option_value('scrollback', 10000, {}) + api.nvim_set_option_value('scrollback', 10000, {}) retry(nil, nil, function() expect_lines(16) end) @@ -494,18 +494,18 @@ describe("'scrollback' option", function() ]]) local term_height = 6 -- Actual terminal screen height, not the scrollback -- Initial - local scrollback = meths.nvim_get_option_value('scrollback', {}) + local scrollback = api.nvim_get_option_value('scrollback', {}) eq(scrollback + term_height, eval('line("$")')) -- Reduction scrollback = scrollback - 2 - meths.nvim_set_option_value('scrollback', scrollback, {}) + api.nvim_set_option_value('scrollback', scrollback, {}) eq(scrollback + term_height, eval('line("$")')) end) it('defaults to 10000 in :terminal buffers', function() set_fake_shell() command('terminal') - eq(10000, meths.nvim_get_option_value('scrollback', {})) + eq(10000, api.nvim_get_option_value('scrollback', {})) end) it('error if set to invalid value', function() @@ -518,7 +518,7 @@ describe("'scrollback' option", function() it('defaults to -1 on normal buffers', function() command('new') - eq(-1, meths.nvim_get_option_value('scrollback', {})) + eq(-1, api.nvim_get_option_value('scrollback', {})) end) it(':setlocal in a :terminal buffer', function() @@ -527,45 +527,45 @@ describe("'scrollback' option", function() -- _Global_ scrollback=-1 defaults :terminal to 10_000. command('setglobal scrollback=-1') command('terminal') - eq(10000, meths.nvim_get_option_value('scrollback', {})) + eq(10000, api.nvim_get_option_value('scrollback', {})) -- _Local_ scrollback=-1 in :terminal forces the _maximum_. command('setlocal scrollback=-1') retry(nil, nil, function() -- Fixup happens on refresh, not immediately. - eq(100000, meths.nvim_get_option_value('scrollback', {})) + eq(100000, api.nvim_get_option_value('scrollback', {})) end) -- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605 command('setglobal scrollback=-1') command('autocmd TermOpen * setlocal scrollback=-1') command('terminal') - eq(100000, meths.nvim_get_option_value('scrollback', {})) + eq(100000, api.nvim_get_option_value('scrollback', {})) end) it(':setlocal in a normal buffer', function() command('new') -- :setlocal to -1. command('setlocal scrollback=-1') - eq(-1, meths.nvim_get_option_value('scrollback', {})) + eq(-1, api.nvim_get_option_value('scrollback', {})) -- :setlocal to anything except -1. Currently, this just has no effect. command('setlocal scrollback=42') - eq(42, meths.nvim_get_option_value('scrollback', {})) + eq(42, api.nvim_get_option_value('scrollback', {})) end) it(':set updates local value and global default', function() set_fake_shell() command('set scrollback=42') -- set global value - eq(42, meths.nvim_get_option_value('scrollback', {})) + eq(42, api.nvim_get_option_value('scrollback', {})) command('terminal') - eq(42, meths.nvim_get_option_value('scrollback', {})) -- inherits global default + eq(42, api.nvim_get_option_value('scrollback', {})) -- inherits global default command('setlocal scrollback=99') - eq(99, meths.nvim_get_option_value('scrollback', {})) + eq(99, api.nvim_get_option_value('scrollback', {})) command('set scrollback<') -- reset to global default - eq(42, meths.nvim_get_option_value('scrollback', {})) + eq(42, api.nvim_get_option_value('scrollback', {})) command('setglobal scrollback=734') -- new global default - eq(42, meths.nvim_get_option_value('scrollback', {})) -- local value did not change + eq(42, api.nvim_get_option_value('scrollback', {})) -- local value did not change command('terminal') - eq(734, meths.nvim_get_option_value('scrollback', {})) + eq(734, api.nvim_get_option_value('scrollback', {})) end) end) -- cgit