aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal')
-rw-r--r--test/functional/terminal/altscreen_spec.lua54
-rw-r--r--test/functional/terminal/api_spec.lua57
-rw-r--r--test/functional/terminal/buffer_spec.lua371
-rw-r--r--test/functional/terminal/channel_spec.lua199
-rw-r--r--test/functional/terminal/cursor_spec.lua582
-rw-r--r--test/functional/terminal/edit_spec.lua48
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua223
-rw-r--r--test/functional/terminal/helpers.lua150
-rw-r--r--test/functional/terminal/highlight_spec.lua209
-rw-r--r--test/functional/terminal/mouse_spec.lua136
-rw-r--r--test/functional/terminal/scrollback_spec.lua211
-rw-r--r--test/functional/terminal/tui_spec.lua2132
-rw-r--r--test/functional/terminal/window_spec.lua68
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua38
14 files changed, 2560 insertions, 1918 deletions
diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua
index cbe5e06005..c3be9ec6ca 100644
--- a/test/functional/terminal/altscreen_spec.lua
+++ b/test/functional/terminal/altscreen_spec.lua
@@ -1,12 +1,14 @@
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, api = helpers.clear, helpers.eq, helpers.api
local feed = helpers.feed
local feed_data = thelpers.feed_data
local enter_altscreen = thelpers.enter_altscreen
local exit_altscreen = thelpers.exit_altscreen
-if helpers.skip(helpers.is_os('win')) then return end
+if helpers.skip(helpers.is_os('win')) then
+ return
+end
describe(':terminal altscreen', function()
local screen
@@ -14,8 +16,17 @@ describe(':terminal altscreen', function()
before_each(function()
clear()
screen = thelpers.screen_setup()
- feed_data({'line1', 'line2', 'line3', 'line4', 'line5', 'line6',
- 'line7', 'line8', ''})
+ feed_data({
+ 'line1',
+ 'line2',
+ 'line3',
+ 'line4',
+ 'line5',
+ 'line6',
+ 'line7',
+ 'line8',
+ '',
+ })
screen:expect([[
line4 |
line5 |
@@ -27,15 +38,11 @@ describe(':terminal altscreen', function()
]])
enter_altscreen()
screen:expect([[
- |
- |
- |
- |
- |
+ |*5
{1: } |
{3:-- TERMINAL --} |
]])
- eq(10, curbuf('line_count'))
+ eq(10, api.nvim_buf_line_count(0))
end)
it('wont clear lines already in the scrollback', function()
@@ -45,9 +52,7 @@ describe(':terminal altscreen', function()
line1 |
line2 |
line3 |
- |
- |
- |
+ |*3
]])
end)
@@ -79,8 +84,17 @@ describe(':terminal altscreen', function()
describe('with lines printed after the screen height limit', function()
before_each(function()
- feed_data({'line9', 'line10', 'line11', 'line12', 'line13',
- 'line14', 'line15', 'line16', ''})
+ feed_data({
+ 'line9',
+ 'line10',
+ 'line11',
+ 'line12',
+ 'line13',
+ 'line14',
+ 'line15',
+ 'line16',
+ '',
+ })
screen:expect([[
line12 |
line13 |
@@ -93,7 +107,7 @@ describe(':terminal altscreen', function()
end)
it('wont modify line count', function()
- eq(10, curbuf('line_count'))
+ eq(10, api.nvim_buf_line_count(0))
end)
it('wont modify lines in the scrollback', function()
@@ -114,8 +128,7 @@ describe(':terminal altscreen', function()
local function wait_removal()
screen:try_resize(screen._width, screen._height - 2)
screen:expect([[
- |
- |
+ |*2
rows: 4, cols: 50 |
{1: } |
{3:-- TERMINAL --} |
@@ -127,12 +140,11 @@ describe(':terminal altscreen', function()
feed('<c-\\><c-n>4k')
screen:expect([[
^ |
- |
- |
+ |*2
rows: 4, cols: 50 |
|
]])
- eq(9, curbuf('line_count'))
+ eq(9, api.nvim_buf_line_count(0))
end)
describe('and after exit', function()
diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua
index 93641fc576..79cc5016da 100644
--- a/test/functional/terminal/api_spec.lua
+++ b/test/functional/terminal/api_spec.lua
@@ -2,67 +2,70 @@ local helpers = require('test.functional.helpers')(after_each)
local child_session = require('test.functional.terminal.helpers')
local ok = helpers.ok
-if helpers.skip(helpers.is_os('win')) then return end
+if helpers.skip(helpers.is_os('win')) then
+ return
+end
describe('api', function()
local screen
- local socket_name = "./Xtest_functional_api.sock"
+ local socket_name = './Xtest_functional_api.sock'
before_each(function()
helpers.clear()
os.remove(socket_name)
- screen = child_session.screen_setup(0, '["'..helpers.nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--cmd", "'..helpers.nvim_set..'"]')
+ screen = child_session.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ helpers.nvim_set .. ' notermguicolors',
+ })
end)
after_each(function()
os.remove(socket_name)
end)
- it("qa! RPC request during insert-mode", function()
- screen:expect{grid=[[
+ it('qa! RPC request during insert-mode', function()
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*4
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
-- Start the socket from the child nvim.
- child_session.feed_data(":echo serverstart('"..socket_name.."')\n")
+ child_session.feed_data(":echo serverstart('" .. socket_name .. "')\n")
-- Wait for socket creation.
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
- ]]..socket_name..[[ |
+ {4:~ }|*4
+ ]] .. socket_name .. [[ |
{3:-- TERMINAL --} |
]])
local socket_session1 = helpers.connect(socket_name)
local socket_session2 = helpers.connect(socket_name)
- child_session.feed_data("i[tui] insert-mode")
+ child_session.feed_data('i[tui] insert-mode')
-- Wait for stdin to be processed.
screen:expect([[
[tui] insert-mode{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*4
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- ok((socket_session1:request("nvim_ui_attach", 42, 6, {rgb=true})))
- ok((socket_session2:request("nvim_ui_attach", 25, 30, {rgb=true})))
+ ok((socket_session1:request('nvim_ui_attach', 42, 6, { rgb = true })))
+ ok((socket_session2:request('nvim_ui_attach', 25, 30, { rgb = true })))
- socket_session1:notify("nvim_input", "\n[socket 1] this is more than 25 columns")
- socket_session2:notify("nvim_input", "\n[socket 2] input")
+ socket_session1:notify('nvim_input', '\n[socket 1] this is more than 25 columns')
+ socket_session2:notify('nvim_input', '\n[socket 2] input')
screen:expect([[
[tui] insert-mode |
@@ -74,6 +77,6 @@ describe('api', function()
{3:-- TERMINAL --} |
]])
- socket_session1:request("nvim_command", "qa!")
+ socket_session1:request('nvim_command', 'qa!')
end)
end)
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 6fcd029a5b..376b7b849e 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -1,23 +1,24 @@
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local assert_alive = helpers.assert_alive
-local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
+local feed, clear = helpers.feed, helpers.clear
local poke_eventloop = helpers.poke_eventloop
+local nvim_prog = helpers.nvim_prog
local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source
local pcall_err = helpers.pcall_err
local eq, neq = helpers.eq, helpers.neq
-local meths = helpers.meths
+local api = helpers.api
local retry = helpers.retry
local write_file = helpers.write_file
local command = helpers.command
local exc_exec = helpers.exc_exec
local matches = helpers.matches
local exec_lua = helpers.exec_lua
-local sleep = helpers.sleep
-local funcs = helpers.funcs
+local sleep = vim.uv.sleep
+local fn = helpers.fn
local is_os = helpers.is_os
local skip = helpers.skip
-local nvim_prog = helpers.nvim_prog
describe(':terminal buffer', function()
local screen
@@ -31,13 +32,19 @@ describe(':terminal buffer', function()
it('terminal-mode forces various options', function()
feed([[<C-\><C-N>]])
command('setlocal cursorline cursorlineopt=both cursorcolumn scrolloff=4 sidescrolloff=7')
- eq({ 'both', 1, 1, 4, 7 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
+ eq(
+ { 'both', 1, 1, 4, 7 },
+ eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]')
+ )
eq('nt', eval('mode(1)'))
-- Enter terminal-mode ("insert" mode in :terminal).
feed('i')
eq('t', eval('mode(1)'))
- eq({ 'number', 1, 0, 0, 0 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
+ eq(
+ { 'number', 1, 0, 0, 0 },
+ eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]')
+ )
end)
it('terminal-mode does not change cursorlineopt if cursorline is disabled', function()
@@ -59,11 +66,7 @@ describe(':terminal buffer', function()
feed('<c-\\><c-n>:set bufhidden=wipe<cr>:enew<cr>')
screen:expect([[
^ |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*5
:enew |
]])
end)
@@ -72,11 +75,7 @@ describe(':terminal buffer', function()
feed(':bnext:l<esc>')
screen:expect([[
^ |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*5
|
]])
end)
@@ -88,21 +87,17 @@ describe(':terminal buffer', function()
screen:expect([[
tty ready |
{2:^ } |
- |
- |
- |
- |
- |
+ |*5
]])
end)
it('does not create swap files', function()
- local swapfile = nvim('exec', 'swapname', true):gsub('\n', '')
+ local swapfile = api.nvim_exec('swapname', true):gsub('\n', '')
eq(nil, io.open(swapfile))
end)
it('does not create undofiles files', function()
- local undofile = nvim('eval', 'undofile(bufname("%"))')
+ local undofile = api.nvim_eval('undofile(bufname("%"))')
eq(nil, io.open(undofile))
end)
end)
@@ -112,10 +107,7 @@ describe(':terminal buffer', function()
screen:expect([[
tty ready |
{2:^ } |
- |
- |
- |
- |
+ |*4
{8:E21: Cannot make changes, 'modifiable' is off} |
]])
end)
@@ -126,22 +118,16 @@ describe(':terminal buffer', function()
feed('"ap"ap')
screen:expect([[
^tty ready |
- appended tty ready |
- appended tty ready |
+ appended tty ready |*2
{2: } |
- |
- |
+ |*2
:let @a = "appended " . @a |
]])
-- operator count is also taken into consideration
feed('3"ap')
screen:expect([[
^tty ready |
- appended tty ready |
- appended tty ready |
- appended tty ready |
- appended tty ready |
- appended tty ready |
+ appended tty ready |*5
:let @a = "appended " . @a |
]])
end)
@@ -154,17 +140,14 @@ describe(':terminal buffer', function()
^tty ready |
appended tty ready |
{2: } |
- |
- |
- |
+ |*3
:put a |
]])
-- line argument is only used to move the cursor
feed_command('6put a')
screen:expect([[
tty ready |
- appended tty ready |
- appended tty ready |
+ appended tty ready |*2
{2: } |
|
^ |
@@ -176,34 +159,24 @@ describe(':terminal buffer', function()
feed('<c-\\><c-n>:bd!<cr>')
screen:expect([[
^ |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*5
:bd! |
]])
feed_command('bnext')
screen:expect([[
^ |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*5
:bnext |
]])
end)
it('handles loss of focus gracefully', function()
-- Change the statusline to avoid printing the file name, which varies.
- nvim('set_option_value', 'statusline', '==========', {})
+ api.nvim_set_option_value('statusline', '==========', {})
-- Save the buffer number of the terminal for later testing.
local tbuf = eval('bufnr("%")')
- local exitcmd = is_os('win')
- and "['cmd', '/c', 'exit']"
- or "['sh', '-c', 'exit']"
+ local exitcmd = is_os('win') and "['cmd', '/c', 'exit']" or "['sh', '-c', 'exit']"
source([[
function! SplitWindow(id, data, event)
new
@@ -211,7 +184,7 @@ describe(':terminal buffer', function()
endfunction
startinsert
- call jobstart(]]..exitcmd..[[, {'on_exit': function("SplitWindow")})
+ call jobstart(]] .. exitcmd .. [[, {'on_exit': function("SplitWindow")})
call feedkeys("\<C-\>", 't') " vim will expect <C-n>, but be exited out of
" the terminal before it can be entered.
]])
@@ -228,7 +201,7 @@ describe(':terminal buffer', function()
]])
neq(tbuf, eval('bufnr("%")'))
- feed_command('quit!') -- Should exit the new window, not the terminal.
+ feed_command('quit!') -- Should exit the new window, not the terminal.
eq(tbuf, eval('bufnr("%")'))
end)
@@ -243,46 +216,46 @@ describe(':terminal buffer', function()
feed_command('terminal')
feed('<c-\\><c-n>')
feed_command('confirm bdelete')
- screen:expect{any='Close "term://'}
+ screen:expect { any = 'Close "term://' }
end)
it('with &confirm', function()
feed_command('terminal')
feed('<c-\\><c-n>')
feed_command('bdelete')
- screen:expect{any='E89'}
+ screen:expect { any = 'E89' }
feed('<cr>')
eq('terminal', eval('&buftype'))
feed_command('set confirm | bdelete')
- screen:expect{any='Close "term://'}
+ screen:expect { any = 'Close "term://' }
feed('y')
neq('terminal', eval('&buftype'))
end)
end)
it('it works with set rightleft #11438', function()
- skip(is_os('win'))
local columns = eval('&columns')
feed(string.rep('a', columns))
command('set rightleft')
screen:expect([[
ydaer ytt|
{1:a}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
]])
command('bdelete!')
end)
it('requires bang (!) to close a running job #15402', function()
- skip(is_os('win'), "Test freezes the CI and makes it time out")
+ skip(is_os('win'), 'Test freezes the CI and makes it time out')
eq('Vim(wqall):E948: Job still running', exc_exec('wqall'))
for _, cmd in ipairs({ 'bdelete', '%bdelete', 'bwipeout', 'bunload' }) do
- matches('^Vim%('..cmd:gsub('%%', '')..'%):E89: term://.*tty%-test.* will be killed %(add %! to override%)$',
- exc_exec(cmd))
+ matches(
+ '^Vim%('
+ .. cmd:gsub('%%', '')
+ .. '%):E89: term://.*tty%-test.* will be killed %(add %! to override%)$',
+ exc_exec(cmd)
+ )
end
command('call jobstop(&channel)')
assert(0 >= eval('jobwait([&channel], 1000)[0]'))
@@ -299,51 +272,97 @@ describe(':terminal buffer', function()
it('does not segfault when pasting empty register #13955', function()
feed('<c-\\><c-n>')
- feed_command('put a') -- register a is empty
+ feed_command('put a') -- register a is empty
helpers.assert_alive()
end)
it([[can use temporary normal mode <c-\><c-o>]], function()
- eq('t', funcs.mode(1))
+ eq('t', fn.mode(1))
feed [[<c-\><c-o>]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tty ready |
{2:^ } |
- |
- |
- |
- |
+ |*4
{3:-- (terminal) --} |
- ]]}
- eq('ntT', funcs.mode(1))
+ ]],
+ }
+ eq('ntT', fn.mode(1))
feed [[:let g:x = 17]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tty ready |
{2: } |
- |
- |
- |
- |
+ |*4
:let g:x = 17^ |
- ]]}
+ ]],
+ }
feed [[<cr>]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tty ready |
{1: } |
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
- ]]}
- eq('t', funcs.mode(1))
+ ]],
+ }
+ eq('t', fn.mode(1))
end)
it('writing to an existing file with :w fails #13549', function()
- eq('Vim(write):E13: File exists (add ! to override)',
- pcall_err(command, 'write test/functional/fixtures/tty-test.c'))
+ eq(
+ 'Vim(write):E13: File exists (add ! to override)',
+ pcall_err(command, 'write test/functional/fixtures/tty-test.c')
+ )
+ end)
+
+ it('emits TermRequest events #26972', function()
+ command('new')
+ local term = api.nvim_open_term(0, {})
+ local termbuf = api.nvim_get_current_buf()
+
+ -- Test that autocommand buffer is associated with the terminal buffer, not the current buffer
+ command('au TermRequest * let g:termbuf = +expand("<abuf>")')
+ command('wincmd p')
+
+ -- cwd will be inserted in a file URI, which cannot contain backs
+ local cwd = fn.getcwd():gsub('\\', '/')
+ local parent = cwd:match('^(.+/)')
+ local expected = '\027]7;file://host' .. parent
+ api.nvim_chan_send(term, string.format('%s\027\\', expected))
+ eq(expected, eval('v:termrequest'))
+ eq(termbuf, eval('g:termbuf'))
+ end)
+
+ it('TermReqeust synchronization #27572', function()
+ command('new')
+ command('autocmd! nvim_terminal TermRequest')
+ local term = exec_lua([[
+ _G.input = {}
+ local term = vim.api.nvim_open_term(0, {
+ on_input = function(_, _, _, data)
+ table.insert(_G.input, data)
+ end,
+ force_crlf = false,
+ })
+ vim.api.nvim_create_autocmd('TermRequest', {
+ callback = function(args)
+ if args.data == '\027]11;?' then
+ table.insert(_G.input, '\027]11;rgb:0000/0000/0000\027\\')
+ end
+ end
+ })
+ return term
+ ]])
+ api.nvim_chan_send(term, '\027]11;?\007\027[5n\027]11;?\007\027[5n')
+ eq({
+ '\027]11;rgb:0000/0000/0000\027\\',
+ '\027[0n',
+ '\027]11;rgb:0000/0000/0000\027\\',
+ '\027[0n',
+ }, exec_lua('return _G.input'))
end)
end)
@@ -351,7 +370,7 @@ describe('No heap-buffer-overflow when using', function()
local testfilename = 'Xtestfile-functional-terminal-buffers_spec'
before_each(function()
- write_file(testfilename, "aaaaaaaaaaaaaaaaaaaaaaaaaaaa")
+ write_file(testfilename, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa')
end)
after_each(function()
@@ -414,10 +433,12 @@ end)
it('terminal truncates number of composing characters to 5', function()
clear()
- local chan = meths.open_term(0, {})
+ local chan = api.nvim_open_term(0, {})
local composing = ('a̳'):sub(2)
- meths.chan_send(chan, 'a' .. composing:rep(8))
- retry(nil, nil, function() eq('a' .. composing:rep(5), meths.get_current_line()) end)
+ api.nvim_chan_send(chan, 'a' .. composing:rep(8))
+ retry(nil, nil, function()
+ eq('a' .. composing:rep(5), api.nvim_get_current_line())
+ end)
end)
describe('terminal input', function()
@@ -447,31 +468,80 @@ end)
describe('terminal input', function()
it('sends various special keys with modifiers', function()
clear()
- local screen = thelpers.screen_setup(0,
- string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--cmd", "startinsert"]]=], nvim_prog))
- screen:expect{grid=[[
+ local screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set notermguicolors',
+ '--cmd',
+ 'startinsert',
+ })
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] 0,1 All}|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
for _, key in ipairs({
- '<M-Tab>', '<M-CR>', '<M-Esc>',
- '<BS>', '<S-Tab>', '<Insert>', '<Del>', '<PageUp>', '<PageDown>',
- '<S-Up>', '<C-Up>', '<Up>', '<S-Down>', '<C-Down>', '<Down>',
- '<S-Left>', '<C-Left>', '<Left>', '<S-Right>', '<C-Right>', '<Right>',
- '<S-Home>', '<C-Home>', '<Home>', '<S-End>', '<C-End>', '<End>',
- '<C-LeftMouse>', '<C-LeftRelease>', '<2-LeftMouse>', '<2-LeftRelease>',
- '<S-RightMouse>', '<S-RightRelease>', '<2-RightMouse>', '<2-RightRelease>',
- '<M-MiddleMouse>', '<M-MiddleRelease>', '<2-MiddleMouse>', '<2-MiddleRelease>',
- '<S-ScrollWheelUp>', '<S-ScrollWheelDown>', '<ScrollWheelUp>', '<ScrollWheelDown>',
- '<S-ScrollWheelLeft>', '<S-ScrollWheelRight>', '<ScrollWheelLeft>', '<ScrollWheelRight>',
+ '<M-Tab>',
+ '<M-CR>',
+ '<M-Esc>',
+ '<BS>',
+ '<S-Tab>',
+ '<Insert>',
+ '<Del>',
+ '<PageUp>',
+ '<PageDown>',
+ '<S-Up>',
+ '<C-Up>',
+ '<Up>',
+ '<S-Down>',
+ '<C-Down>',
+ '<Down>',
+ '<S-Left>',
+ '<C-Left>',
+ '<Left>',
+ '<S-Right>',
+ '<C-Right>',
+ '<Right>',
+ '<S-Home>',
+ '<C-Home>',
+ '<Home>',
+ '<S-End>',
+ '<C-End>',
+ '<End>',
+ '<C-LeftMouse>',
+ '<C-LeftRelease>',
+ '<2-LeftMouse>',
+ '<2-LeftRelease>',
+ '<S-RightMouse>',
+ '<S-RightRelease>',
+ '<2-RightMouse>',
+ '<2-RightRelease>',
+ '<M-MiddleMouse>',
+ '<M-MiddleRelease>',
+ '<2-MiddleMouse>',
+ '<2-MiddleRelease>',
+ '<S-ScrollWheelUp>',
+ '<S-ScrollWheelDown>',
+ '<ScrollWheelUp>',
+ '<ScrollWheelDown>',
+ '<S-ScrollWheelLeft>',
+ '<S-ScrollWheelRight>',
+ '<ScrollWheelLeft>',
+ '<ScrollWheelRight>',
}) do
feed('<CR><C-V>' .. key)
- retry(nil, nil, function() eq(key, meths.get_current_line()) end)
+ retry(nil, nil, function()
+ eq(key, api.nvim_get_current_line())
+ end)
end
end)
end)
@@ -484,7 +554,7 @@ if is_os('win') then
clear()
feed_command('set modifiable swapfile undolevels=20')
poke_eventloop()
- local cmd = '["cmd.exe","/K","PROMPT=$g$s"]'
+ local cmd = { 'cmd.exe', '/K', 'PROMPT=$g$s' }
screen = thelpers.screen_setup(nil, cmd)
end)
@@ -549,11 +619,70 @@ describe('termopen()', function()
it('disallowed when textlocked and in cmdwin buffer', function()
command("autocmd TextYankPost <buffer> ++once call termopen('foo')")
- matches("Vim%(call%):E565: Not allowed to change text or change window$",
- pcall_err(command, "normal! yy"))
+ matches(
+ 'Vim%(call%):E565: Not allowed to change text or change window$',
+ pcall_err(command, 'normal! yy')
+ )
+
+ feed('q:')
+ eq(
+ 'Vim:E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
+ pcall_err(fn.termopen, 'bar')
+ )
+ end)
+
+ describe('$COLORTERM value', function()
+ if skip(is_os('win'), 'Not applicable for Windows') then
+ return
+ end
- feed("q:")
- eq("Vim:E11: Invalid in command-line window; <CR> executes, CTRL-C quits",
- pcall_err(funcs.termopen, "bar"))
+ before_each(function()
+ -- Outer value should never be propagated to :terminal
+ fn.setenv('COLORTERM', 'wrongvalue')
+ end)
+
+ local function test_term_colorterm(expected, opts)
+ local screen = Screen.new(50, 4)
+ screen:attach()
+ fn.termopen({
+ nvim_prog,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--headless',
+ '-c',
+ 'echo $COLORTERM | quit',
+ }, opts)
+ screen:expect(([[
+ ^%s{MATCH:%%s+}|
+ [Process exited 0] |
+ |*2
+ ]]):format(expected))
+ end
+
+ describe("with 'notermguicolors'", function()
+ before_each(function()
+ command('set notermguicolors')
+ end)
+ it('is empty by default', function()
+ test_term_colorterm('')
+ end)
+ it('can be overridden', function()
+ test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } })
+ end)
+ end)
+
+ describe("with 'termguicolors'", function()
+ before_each(function()
+ command('set termguicolors')
+ end)
+ it('is "truecolor" by default', function()
+ test_term_colorterm('truecolor')
+ end)
+ it('can be overridden', function()
+ test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } })
+ end)
+ end)
end)
end)
diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua
index 8510df5347..9615534c87 100644
--- a/test/functional/terminal/channel_spec.lua
+++ b/test/functional/terminal/channel_spec.lua
@@ -8,7 +8,7 @@ local pcall_err = helpers.pcall_err
local feed = helpers.feed
local poke_eventloop = helpers.poke_eventloop
local is_os = helpers.is_os
-local meths = helpers.meths
+local api = helpers.api
local async_meths = helpers.async_meths
local testprg = helpers.testprg
local assert_alive = helpers.assert_alive
@@ -26,9 +26,11 @@ describe('terminal channel is closed and later released if', function()
command([[let id = nvim_open_term(0, {})]])
local chans = eval('len(nvim_list_chans())')
-- channel hasn't been released yet
- eq("Vim(call):Can't send data to closed stream",
- pcall_err(command, [[bdelete! | call chansend(id, 'test')]]))
- feed('<Ignore>') -- add input to separate two RPC requests
+ eq(
+ "Vim(call):Can't send data to closed stream",
+ pcall_err(command, [[bdelete! | call chansend(id, 'test')]])
+ )
+ feed('<Ignore>') -- add input to separate two RPC requests
-- channel has been released after one main loop iteration
eq(chans - 1, eval('len(nvim_list_chans())'))
end)
@@ -37,15 +39,17 @@ describe('terminal channel is closed and later released if', function()
command('let id = nvim_open_term(0, {})')
local chans = eval('len(nvim_list_chans())')
-- channel has been closed but not released
- eq("Vim(call):Can't send data to closed stream",
- pcall_err(command, [[call chanclose(id) | call chansend(id, 'test')]]))
- screen:expect({any='%[Terminal closed%]'})
+ eq(
+ "Vim(call):Can't send data to closed stream",
+ pcall_err(command, [[call chanclose(id) | call chansend(id, 'test')]])
+ )
+ screen:expect({ any = '%[Terminal closed%]' })
eq(chans, eval('len(nvim_list_chans())'))
-- delete terminal
feed('i<CR>')
-- need to first process input
poke_eventloop()
- feed('<Ignore>') -- add input to separate two RPC requests
+ feed('<Ignore>') -- add input to separate two RPC requests
-- channel has been released after another main loop iteration
eq(chans - 1, eval('len(nvim_list_chans())'))
end)
@@ -54,14 +58,18 @@ describe('terminal channel is closed and later released if', function()
command('let id = nvim_open_term(0, {})')
local chans = eval('len(nvim_list_chans())')
-- channel has been closed but not released
- eq("Vim(call):Can't send data to closed stream",
- pcall_err(command, [[call chanclose(id) | call chansend(id, 'test')]]))
- screen:expect({any='%[Terminal closed%]'})
+ eq(
+ "Vim(call):Can't send data to closed stream",
+ pcall_err(command, [[call chanclose(id) | call chansend(id, 'test')]])
+ )
+ screen:expect({ any = '%[Terminal closed%]' })
eq(chans, eval('len(nvim_list_chans())'))
-- channel still hasn't been released yet
- eq("Vim(call):Can't send data to closed stream",
- pcall_err(command, [[bdelete | call chansend(id, 'test')]]))
- feed('<Ignore>') -- add input to separate two RPC requests
+ eq(
+ "Vim(call):Can't send data to closed stream",
+ pcall_err(command, [[bdelete | call chansend(id, 'test')]])
+ )
+ feed('<Ignore>') -- add input to separate two RPC requests
-- channel has been released after one main loop iteration
eq(chans - 1, eval('len(nvim_list_chans())'))
end)
@@ -70,16 +78,18 @@ describe('terminal channel is closed and later released if', function()
command([[let id = termopen('echo')]])
local chans = eval('len(nvim_list_chans())')
-- wait for process to exit
- screen:expect({any='%[Process exited 0%]'})
+ screen:expect({ any = '%[Process exited 0%]' })
-- process has exited but channel has't been released
- eq("Vim(call):Can't send data to closed stream",
- pcall_err(command, [[call chansend(id, 'test')]]))
+ eq(
+ "Vim(call):Can't send data to closed stream",
+ pcall_err(command, [[call chansend(id, 'test')]])
+ )
eq(chans, eval('len(nvim_list_chans())'))
-- delete terminal
feed('i<CR>')
-- need to first process input
poke_eventloop()
- feed('<Ignore>') -- add input to separate two RPC requests
+ feed('<Ignore>') -- add input to separate two RPC requests
-- channel has been released after another main loop iteration
eq(chans - 1, eval('len(nvim_list_chans())'))
end)
@@ -89,34 +99,38 @@ describe('terminal channel is closed and later released if', function()
command([[let id = termopen('echo')]])
local chans = eval('len(nvim_list_chans())')
-- wait for process to exit
- screen:expect({any='%[Process exited 0%]'})
+ screen:expect({ any = '%[Process exited 0%]' })
-- process has exited but channel hasn't been released
- eq("Vim(call):Can't send data to closed stream",
- pcall_err(command, [[call chansend(id, 'test')]]))
+ eq(
+ "Vim(call):Can't send data to closed stream",
+ pcall_err(command, [[call chansend(id, 'test')]])
+ )
eq(chans, eval('len(nvim_list_chans())'))
-- channel still hasn't been released yet
- eq("Vim(call):Can't send data to closed stream",
- pcall_err(command, [[bdelete | call chansend(id, 'test')]]))
- feed('<Ignore>') -- add input to separate two RPC requests
+ eq(
+ "Vim(call):Can't send data to closed stream",
+ pcall_err(command, [[bdelete | call chansend(id, 'test')]])
+ )
+ feed('<Ignore>') -- add input to separate two RPC requests
-- channel has been released after one main loop iteration
eq(chans - 1, eval('len(nvim_list_chans())'))
end)
end)
it('chansend sends lines to terminal channel in proper order', function()
- clear({args = {'--cmd', 'set laststatus=2'}})
+ clear({ args = { '--cmd', 'set laststatus=2' } })
local screen = Screen.new(100, 20)
screen:attach()
- local shells = is_os('win') and {'cmd.exe', 'pwsh.exe -nop', 'powershell.exe -nop'} or {'sh'}
+ local shells = is_os('win') and { 'cmd.exe', 'pwsh.exe -nop', 'powershell.exe -nop' } or { 'sh' }
for _, sh in ipairs(shells) do
command([[let id = termopen(']] .. sh .. [[')]])
command([[call chansend(id, ['echo "hello"', 'echo "world"', ''])]])
- screen:expect{
- any=[[echo "hello".*echo "world"]]
+ screen:expect {
+ any = [[echo "hello".*echo "world"]],
}
command('bdelete!')
- screen:expect{
- any='%[No Name%]'
+ screen:expect {
+ any = '%[No Name%]',
}
end
end)
@@ -126,76 +140,139 @@ describe('no crash when TermOpen autocommand', function()
before_each(function()
clear()
- meths.set_option_value('shell', testprg('shell-test'), {})
+ api.nvim_set_option_value('shell', testprg('shell-test'), {})
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
screen = Screen.new(60, 4)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue};
+ [0] = { bold = true, foreground = Screen.colors.Blue },
})
screen:attach()
end)
it('processes job exit event when using termopen()', function()
command([[autocmd TermOpen * call input('')]])
- async_meths.command('terminal foobar')
- screen:expect{grid=[[
+ async_meths.nvim_command('terminal foobar')
+ screen:expect {
+ grid = [[
|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
^ |
- ]]}
+ ]],
+ }
feed('<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ready $ foobar |
|
[Process exited 0] |
|
- ]]}
+ ]],
+ }
feed('i<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
|
- ]]}
+ ]],
+ }
assert_alive()
end)
it('wipes buffer and processes events when using termopen()', function()
command([[autocmd TermOpen * bwipe! | call input('')]])
- async_meths.command('terminal foobar')
- screen:expect{grid=[[
+ async_meths.nvim_command('terminal foobar')
+ screen:expect {
+ grid = [[
|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
^ |
- ]]}
+ ]],
+ }
feed('<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
|
- ]]}
+ ]],
+ }
assert_alive()
end)
it('wipes buffer and processes events when using nvim_open_term()', function()
command([[autocmd TermOpen * bwipe! | call input('')]])
- async_meths.open_term(0, {})
- screen:expect{grid=[[
+ async_meths.nvim_open_term(0, {})
+ screen:expect {
+ grid = [[
|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
^ |
- ]]}
+ ]],
+ }
feed('<CR>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
|
- ]]}
+ ]],
+ }
assert_alive()
end)
end)
+
+describe('nvim_open_term', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(8, 10)
+ screen:attach()
+ end)
+
+ it('with force_crlf=true converts newlines', function()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_create_buf(false, true)
+ local term = api.nvim_open_term(buf, { force_crlf = true })
+ api.nvim_win_set_buf(win, buf)
+ api.nvim_chan_send(term, 'here\nthere\nfoo\r\nbar\n\ntest')
+ screen:expect {
+ grid = [[
+ ^here |
+ there |
+ foo |
+ bar |
+ |
+ test |
+ |*4
+ ]],
+ }
+ api.nvim_chan_send(term, '\nfirst')
+ screen:expect {
+ grid = [[
+ ^here |
+ there |
+ foo |
+ bar |
+ |
+ test |
+ first |
+ |*3
+ ]],
+ }
+ end)
+
+ it('with force_crlf=false does not convert newlines', function()
+ local win = api.nvim_get_current_win()
+ local buf = api.nvim_create_buf(false, true)
+ local term = api.nvim_open_term(buf, { force_crlf = false })
+ api.nvim_win_set_buf(win, buf)
+ api.nvim_chan_send(term, 'here\nthere')
+ screen:expect { grid = [[
+ ^here |
+ there |
+ |*8
+ ]] }
+ end)
+end)
diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua
index 8285bcc26e..73fd97203e 100644
--- a/test/functional/terminal/cursor_spec.lua
+++ b/test/functional/terminal/cursor_spec.lua
@@ -1,9 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
-local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
+local feed, clear = helpers.feed, helpers.clear
local testprg, command = helpers.testprg, helpers.command
-local nvim_prog = helpers.nvim_prog
local eq, eval = helpers.eq, helpers.eval
local matches = helpers.matches
local poke_eventloop = helpers.poke_eventloop
@@ -20,16 +19,12 @@ describe(':terminal cursor', function()
screen = thelpers.screen_setup()
end)
-
it('moves the screen cursor when focused', function()
thelpers.feed_data('testing cursor')
screen:expect([[
tty ready |
testing cursor{1: } |
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
]])
end)
@@ -39,11 +34,7 @@ describe(':terminal cursor', function()
screen:expect([[
tty ready |
{2:^ } |
- |
- |
- |
- |
- |
+ |*5
]])
end)
@@ -94,21 +85,14 @@ describe(':terminal cursor', function()
hide_cursor()
screen:expect([[
tty ready |
- |
- |
- |
- |
- |
+ |*5
{3:-- TERMINAL --} |
]])
show_cursor()
screen:expect([[
tty ready |
{1: } |
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
]])
-- same for when the terminal is unfocused
@@ -117,42 +101,33 @@ describe(':terminal cursor', function()
screen:expect([[
tty ready |
^ |
- |
- |
- |
- |
- |
+ |*5
]])
show_cursor()
screen:expect([[
tty ready |
{2:^ } |
- |
- |
- |
- |
- |
+ |*5
]])
end)
end)
end)
-
describe('cursor with customized highlighting', function()
local screen
before_each(function()
clear()
- nvim('command', 'highlight TermCursor ctermfg=45 ctermbg=46 cterm=NONE')
- nvim('command', 'highlight TermCursorNC ctermfg=55 ctermbg=56 cterm=NONE')
+ command('highlight TermCursor ctermfg=45 ctermbg=46 cterm=NONE')
+ command('highlight TermCursorNC ctermfg=55 ctermbg=56 cterm=NONE')
screen = Screen.new(50, 7)
screen:set_default_attr_ids({
- [1] = {foreground = 45, background = 46},
- [2] = {foreground = 55, background = 56},
- [3] = {bold = true},
+ [1] = { foreground = 45, background = 46 },
+ [2] = { foreground = 55, background = 56 },
+ [3] = { bold = true },
})
- screen:attach({rgb=false})
- command('call termopen(["'..testprg('tty-test')..'"])')
+ screen:attach({ rgb = false })
+ command('call termopen(["' .. testprg('tty-test') .. '"])')
feed('i')
poke_eventloop()
end)
@@ -161,21 +136,14 @@ describe('cursor with customized highlighting', function()
screen:expect([[
tty ready |
{1: } |
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
]])
feed('<c-\\><c-n>')
screen:expect([[
tty ready |
{2:^ } |
- |
- |
- |
- |
- |
+ |*5
]])
end)
end)
@@ -184,20 +152,37 @@ describe('buffer cursor position is correct in terminal without number column',
local screen
local function setup_ex_register(str)
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..[[", "-u", "NONE", "-i", "NONE", "-E", "--cmd", "let @r = ']]..str..[['", ]]
+ screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '-E',
+ '--cmd',
+ string.format('let @r = "%s"', str),
-- <Left> and <Right> don't always work
- ..[["--cmd", "cnoremap <C-X> <Left>", "--cmd", "cnoremap <C-O> <Right>"]]..']', 70)
+ '--cmd',
+ 'cnoremap <C-X> <Left>',
+ '--cmd',
+ 'cnoremap <C-O> <Right>',
+ '--cmd',
+ 'set notermguicolors',
+ }, {
+ cols = 70,
+ })
+ screen:set_default_attr_ids({
+ [1] = { foreground = 253, background = 11 },
+ [2] = { reverse = true },
+ [3] = { bold = true },
+ [4] = { background = 11 },
+ })
-- Also check for real cursor position, as it is used for stuff like input methods
screen._handle_busy_start = function() end
screen._handle_busy_stop = function() end
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :{1:^ } |
+ :{2:^ } |
{3:-- TERMINAL --} |
]])
end
@@ -212,76 +197,58 @@ describe('buffer cursor position is correct in terminal without number column',
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaaa{1:^ } |
+ :aaaaaaaa{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 9}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 9 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaa^a{2: } |
+ :aaaaaaa^a{4: } |
|
]])
- eq({6, 8}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 8 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaa{1:^a}a |
+ :aaaaaa{2:^a}a |
{3:-- TERMINAL --} |
]])
- eq({6, 7}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 7 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaa^a{2:a}a |
+ :aaaaa^a{4:a}a |
|
]])
- eq({6, 6}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 6 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :a{1:^a}aaaaaa |
+ :a{2:^a}aaaaaa |
{3:-- TERMINAL --} |
]])
- eq({6, 2}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 2 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :^a{2:a}aaaaaa |
+ :^a{4:a}aaaaaa |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
end)
end)
@@ -293,164 +260,135 @@ describe('buffer cursor position is correct in terminal without number column',
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµµµµ{1:^ } |
+ :µµµµµµµµ{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 17}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 17 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµµµ^µ{2: } |
+ :µµµµµµµ^µ{4: } |
|
]])
- eq({6, 15}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 15 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµµ{1:^µ}µ |
+ :µµµµµµ{2:^µ}µ |
{3:-- TERMINAL --} |
]])
- eq({6, 13}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 13 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµ^µ{2:µ}µ |
+ :µµµµµ^µ{4:µ}µ |
|
]])
- eq({6, 11}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 11 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ{1:^µ}µµµµµµ |
+ :µ{2:^µ}µµµµµµ |
{3:-- TERMINAL --} |
]])
- eq({6, 3}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 3 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :^µ{2:µ}µµµµµµ |
+ :^µ{4:µ}µµµµµµ |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
end)
end)
- describe('in a line with single-cell composed multibyte characters and no trailing spaces,', function()
- if skip(is_os('win'), "Encoding problem?") then return end
-
- before_each(function()
- setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳')
- end)
-
- it('at the end', function()
- feed('<C-R>r')
- screen:expect([[
- |
- |
- |
- |
+ describe(
+ 'in a line with single-cell composed multibyte characters and no trailing spaces,',
+ function()
+ if skip(is_os('win'), 'Encoding problem?') then
+ return
+ end
+
+ before_each(function()
+ setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳')
+ end)
+
+ it('at the end', function()
+ feed('<C-R>r')
+ screen:expect([[
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1:^ } |
+ :µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 33}, eval('nvim_win_get_cursor(0)'))
- feed([[<C-\><C-N>]])
- screen:expect([[
- |
- |
- |
- |
+ eq({ 6, 33 }, eval('nvim_win_get_cursor(0)'))
+ feed([[<C-\><C-N>]])
+ screen:expect([[
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳{2: } |
+ :µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳{4: } |
|
]])
- eq({6, 29}, eval('nvim_win_get_cursor(0)'))
- end)
+ eq({ 6, 29 }, eval('nvim_win_get_cursor(0)'))
+ end)
- it('near the end', function()
- feed('<C-R>r<C-X><C-X>')
- screen:expect([[
- |
- |
- |
- |
+ it('near the end', function()
+ feed('<C-R>r<C-X><C-X>')
+ screen:expect([[
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳µ̳{1:^µ̳}µ̳ |
+ :µ̳µ̳µ̳µ̳µ̳µ̳{2:^µ̳}µ̳ |
{3:-- TERMINAL --} |
]])
- eq({6, 25}, eval('nvim_win_get_cursor(0)'))
- feed([[<C-\><C-N>]])
- screen:expect([[
- |
- |
- |
- |
+ eq({ 6, 25 }, eval('nvim_win_get_cursor(0)'))
+ feed([[<C-\><C-N>]])
+ screen:expect([[
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳^µ̳{2:µ̳}µ̳ |
+ :µ̳µ̳µ̳µ̳µ̳^µ̳{4:µ̳}µ̳ |
|
]])
- eq({6, 21}, eval('nvim_win_get_cursor(0)'))
- end)
+ eq({ 6, 21 }, eval('nvim_win_get_cursor(0)'))
+ end)
- it('near the start', function()
- feed('<C-R>r<C-B><C-O>')
- screen:expect([[
- |
- |
- |
- |
+ it('near the start', function()
+ feed('<C-R>r<C-B><C-O>')
+ screen:expect([[
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳{1:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ :µ̳{2:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
{3:-- TERMINAL --} |
]])
- eq({6, 5}, eval('nvim_win_get_cursor(0)'))
- feed([[<C-\><C-N>]])
- screen:expect([[
- |
- |
- |
- |
+ eq({ 6, 5 }, eval('nvim_win_get_cursor(0)'))
+ feed([[<C-\><C-N>]])
+ screen:expect([[
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :^µ̳{2:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ :^µ̳{4:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
- end)
- end)
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
+ end)
+ end
+ )
describe('in a line with double-cell multibyte characters and no trailing spaces,', function()
- if skip(is_os('win'), "Encoding problem?") then return end
+ if skip(is_os('win'), 'Encoding problem?') then
+ return
+ end
before_each(function()
setup_ex_register('哦哦哦哦哦哦哦哦')
@@ -459,76 +397,58 @@ describe('buffer cursor position is correct in terminal without number column',
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦哦哦哦{1:^ } |
+ :哦哦哦哦哦哦哦哦{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 25}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 25 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦哦哦^哦{2: } |
+ :哦哦哦哦哦哦哦^哦{4: } |
|
]])
- eq({6, 22}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 22 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦哦{1:^哦}哦 |
+ :哦哦哦哦哦哦{2:^哦}哦 |
{3:-- TERMINAL --} |
]])
- eq({6, 19}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 19 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦^哦{2:哦}哦 |
+ :哦哦哦哦哦^哦{4:哦}哦 |
|
]])
- eq({6, 16}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 16 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦{1:^哦}哦哦哦哦哦哦 |
+ :哦{2:^哦}哦哦哦哦哦哦 |
{3:-- TERMINAL --} |
]])
- eq({6, 4}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 4 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :^哦{2:哦}哦哦哦哦哦哦 |
+ :^哦{4:哦}哦哦哦哦哦哦 |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
end)
end)
@@ -536,27 +456,21 @@ describe('buffer cursor position is correct in terminal without number column',
setup_ex_register('aaaaaaaa ')
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaaa {1:^ } |
+ :aaaaaaaa {2:^ } |
{3:-- TERMINAL --} |
]])
matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()'))
- eq({6, 13}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 13 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
+ |*4
Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaaa ^ {2: } |
+ :aaaaaaaa ^ {4: } |
|
]])
- eq({6, 12}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 12 }, eval('nvim_win_get_cursor(0)'))
end)
end)
@@ -564,10 +478,31 @@ describe('buffer cursor position is correct in terminal with number column', fun
local screen
local function setup_ex_register(str)
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..[[", "-u", "NONE", "-i", "NONE", "-E", "--cmd", "let @r = ']]..str..[['", ]]
+ screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '-E',
+ '--cmd',
+ string.format('let @r = "%s"', str),
-- <Left> and <Right> don't always work
- ..[["--cmd", "cnoremap <C-X> <Left>", "--cmd", "cnoremap <C-O> <Right>"]]..']', 70)
+ '--cmd',
+ 'cnoremap <C-X> <Left>',
+ '--cmd',
+ 'cnoremap <C-O> <Right>',
+ '--cmd',
+ 'set notermguicolors',
+ }, {
+ cols = 70,
+ })
+ screen:set_default_attr_ids({
+ [1] = { foreground = 253, background = 11 },
+ [2] = { reverse = true },
+ [3] = { bold = true },
+ [4] = { background = 11 },
+ [7] = { foreground = 130 },
+ })
-- Also check for real cursor position, as it is used for stuff like input methods
screen._handle_busy_start = function() end
screen._handle_busy_stop = function() end
@@ -577,7 +512,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:{1:^ } |
+ {7: 6 }:{2:^ } |
{3:-- TERMINAL --} |
]])
end
@@ -600,10 +535,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaaa{1:^ } |
+ {7: 6 }:aaaaaaaa{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 9}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 9 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -611,10 +546,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaa^a{2: } |
+ {7: 6 }:aaaaaaa^a{4: } |
|
]])
- eq({6, 8}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 8 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the end', function()
@@ -625,10 +560,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaa{1:^a}a |
+ {7: 6 }:aaaaaa{2:^a}a |
{3:-- TERMINAL --} |
]])
- eq({6, 7}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 7 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -636,10 +571,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaa^a{2:a}a |
+ {7: 6 }:aaaaa^a{4:a}a |
|
]])
- eq({6, 6}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 6 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the start', function()
@@ -650,10 +585,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:a{1:^a}aaaaaa |
+ {7: 6 }:a{2:^a}aaaaaa |
{3:-- TERMINAL --} |
]])
- eq({6, 2}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 2 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -661,10 +596,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^a{2:a}aaaaaa |
+ {7: 6 }:^a{4:a}aaaaaa |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
end)
end)
@@ -681,10 +616,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµµµµ{1:^ } |
+ {7: 6 }:µµµµµµµµ{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 17}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 17 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -692,10 +627,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµµµ^µ{2: } |
+ {7: 6 }:µµµµµµµ^µ{4: } |
|
]])
- eq({6, 15}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 15 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the end', function()
@@ -706,10 +641,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµµ{1:^µ}µ |
+ {7: 6 }:µµµµµµ{2:^µ}µ |
{3:-- TERMINAL --} |
]])
- eq({6, 13}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 13 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -717,10 +652,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµ^µ{2:µ}µ |
+ {7: 6 }:µµµµµ^µ{4:µ}µ |
|
]])
- eq({6, 11}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 11 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the start', function()
@@ -731,10 +666,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ{1:^µ}µµµµµµ |
+ {7: 6 }:µ{2:^µ}µµµµµµ |
{3:-- TERMINAL --} |
]])
- eq({6, 3}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 3 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -742,98 +677,105 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^µ{2:µ}µµµµµµ |
+ {7: 6 }:^µ{4:µ}µµµµµµ |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
end)
end)
- describe('in a line with single-cell composed multibyte characters and no trailing spaces,', function()
- if skip(is_os('win'), "Encoding problem?") then return end
+ describe(
+ 'in a line with single-cell composed multibyte characters and no trailing spaces,',
+ function()
+ if skip(is_os('win'), 'Encoding problem?') then
+ return
+ end
- before_each(function()
- setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳')
- end)
+ before_each(function()
+ setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳')
+ end)
- it('at the end', function()
- feed('<C-R>r')
- screen:expect([[
+ it('at the end', function()
+ feed('<C-R>r')
+ screen:expect([[
{7: 1 } |
{7: 2 } |
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1:^ } |
+ {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 33}, eval('nvim_win_get_cursor(0)'))
- feed([[<C-\><C-N>]])
- screen:expect([[
+ eq({ 6, 33 }, eval('nvim_win_get_cursor(0)'))
+ feed([[<C-\><C-N>]])
+ screen:expect([[
{7: 1 } |
{7: 2 } |
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳{2: } |
+ {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳{4: } |
|
]])
- eq({6, 29}, eval('nvim_win_get_cursor(0)'))
- end)
+ eq({ 6, 29 }, eval('nvim_win_get_cursor(0)'))
+ end)
- it('near the end', function()
- feed('<C-R>r<C-X><C-X>')
- screen:expect([[
+ it('near the end', function()
+ feed('<C-R>r<C-X><C-X>')
+ screen:expect([[
{7: 1 } |
{7: 2 } |
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳{1:^µ̳}µ̳ |
+ {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳{2:^µ̳}µ̳ |
{3:-- TERMINAL --} |
]])
- eq({6, 25}, eval('nvim_win_get_cursor(0)'))
- feed([[<C-\><C-N>]])
- screen:expect([[
+ eq({ 6, 25 }, eval('nvim_win_get_cursor(0)'))
+ feed([[<C-\><C-N>]])
+ screen:expect([[
{7: 1 } |
{7: 2 } |
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳^µ̳{2:µ̳}µ̳ |
+ {7: 6 }:µ̳µ̳µ̳µ̳µ̳^µ̳{4:µ̳}µ̳ |
|
]])
- eq({6, 21}, eval('nvim_win_get_cursor(0)'))
- end)
+ eq({ 6, 21 }, eval('nvim_win_get_cursor(0)'))
+ end)
- it('near the start', function()
- feed('<C-R>r<C-B><C-O>')
- screen:expect([[
+ it('near the start', function()
+ feed('<C-R>r<C-B><C-O>')
+ screen:expect([[
{7: 1 } |
{7: 2 } |
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳{1:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ {7: 6 }:µ̳{2:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
{3:-- TERMINAL --} |
]])
- eq({6, 5}, eval('nvim_win_get_cursor(0)'))
- feed([[<C-\><C-N>]])
- screen:expect([[
+ eq({ 6, 5 }, eval('nvim_win_get_cursor(0)'))
+ feed([[<C-\><C-N>]])
+ screen:expect([[
{7: 1 } |
{7: 2 } |
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^µ̳{2:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ {7: 6 }:^µ̳{4:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
- end)
- end)
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
+ end)
+ end
+ )
describe('in a line with double-cell multibyte characters and no trailing spaces,', function()
- if skip(is_os('win'), "Encoding problem?") then return end
+ if skip(is_os('win'), 'Encoding problem?') then
+ return
+ end
before_each(function()
setup_ex_register('哦哦哦哦哦哦哦哦')
@@ -847,10 +789,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦哦哦哦{1:^ } |
+ {7: 6 }:哦哦哦哦哦哦哦哦{2:^ } |
{3:-- TERMINAL --} |
]])
- eq({6, 25}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 25 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -858,10 +800,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦哦哦^哦{2: } |
+ {7: 6 }:哦哦哦哦哦哦哦^哦{4: } |
|
]])
- eq({6, 22}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 22 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the end', function()
@@ -872,10 +814,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦哦{1:^哦}哦 |
+ {7: 6 }:哦哦哦哦哦哦{2:^哦}哦 |
{3:-- TERMINAL --} |
]])
- eq({6, 19}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 19 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -883,10 +825,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦^哦{2:哦}哦 |
+ {7: 6 }:哦哦哦哦哦^哦{4:哦}哦 |
|
]])
- eq({6, 16}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 16 }, eval('nvim_win_get_cursor(0)'))
end)
it('near the start', function()
@@ -897,10 +839,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦{1:^哦}哦哦哦哦哦哦 |
+ {7: 6 }:哦{2:^哦}哦哦哦哦哦哦 |
{3:-- TERMINAL --} |
]])
- eq({6, 4}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 4 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -908,10 +850,10 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^哦{2:哦}哦哦哦哦哦哦 |
+ {7: 6 }:^哦{4:哦}哦哦哦哦哦哦 |
|
]])
- eq({6, 1}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 1 }, eval('nvim_win_get_cursor(0)'))
end)
end)
@@ -924,11 +866,11 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaaa {1:^ } |
+ {7: 6 }:aaaaaaaa {2:^ } |
{3:-- TERMINAL --} |
]])
matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()'))
- eq({6, 13}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 13 }, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
{7: 1 } |
@@ -936,9 +878,9 @@ describe('buffer cursor position is correct in terminal with number column', fun
{7: 3 } |
{7: 4 } |
{7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaaa ^ {2: } |
+ {7: 6 }:aaaaaaaa ^ {4: } |
|
]])
- eq({6, 12}, eval('nvim_win_get_cursor(0)'))
+ eq({ 6, 12 }, eval('nvim_win_get_cursor(0)'))
end)
end)
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)
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index f628e261a2..92d37fc04a 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -1,11 +1,12 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive
-local clear, poke_eventloop, nvim = helpers.clear, helpers.poke_eventloop, helpers.nvim
+local clear, poke_eventloop = helpers.clear, helpers.poke_eventloop
local testprg, source, eq = helpers.testprg, helpers.source, helpers.eq
local feed = helpers.feed
local feed_command, eval = helpers.feed_command, helpers.eval
-local funcs = helpers.funcs
+local fn = helpers.fn
+local api = helpers.api
local retry = helpers.retry
local ok = helpers.ok
local command = helpers.command
@@ -19,10 +20,10 @@ describe(':terminal', function()
before_each(function()
clear()
screen = Screen.new(50, 4)
- screen:attach({rgb=false})
+ screen:attach({ rgb = false })
end)
- it("does not interrupt Press-ENTER prompt #2748", function()
+ it('does not interrupt Press-ENTER prompt #2748', function()
-- Ensure that :messages shows Press-ENTER.
source([[
echomsg "msg1"
@@ -30,14 +31,14 @@ describe(':terminal', function()
echomsg "msg3"
]])
-- Invoke a command that emits frequent terminal activity.
- feed([[:terminal "]]..testprg('shell-test')..[[" REP 9999 !terminal_output!<cr>]])
+ feed([[:terminal "]] .. testprg('shell-test') .. [[" REP 9999 !terminal_output!<cr>]])
feed([[<C-\><C-N>]])
poke_eventloop()
-- Wait for some terminal activity.
retry(nil, 4000, function()
- ok(funcs.line('$') > 6)
+ ok(fn.line('$') > 6)
end)
- feed_command("messages")
+ feed_command('messages')
screen:expect([[
msg1 |
msg2 |
@@ -46,36 +47,40 @@ describe(':terminal', function()
]])
end)
- it("reads output buffer on terminal reporting #4151", function()
+ it('reads output buffer on terminal reporting #4151', function()
skip(is_ci('cirrus') or is_os('win'))
if is_os('win') then
- feed_command([[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]])
+ feed_command(
+ [[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]]
+ )
else
feed_command([[terminal printf '\e[6n'; sleep 0.5 ]])
end
- screen:expect{any='%^%[%[1;1R'}
+ screen:expect { any = '%^%[%[1;1R' }
end)
- it("in normal-mode :split does not move cursor", function()
+ it('in normal-mode :split does not move cursor', function()
if is_os('win') then
- feed_command([[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]])
+ feed_command(
+ [[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]]
+ )
else
feed_command([[terminal while true; do echo foo; sleep .1; done]])
end
- feed([[<C-\><C-N>M]]) -- move cursor away from last line
+ feed([[<C-\><C-N>M]]) -- move cursor away from last line
poke_eventloop()
- eq(3, eval("line('$')")) -- window height
- eq(2, eval("line('.')")) -- cursor is in the middle
+ eq(3, eval("line('$')")) -- window height
+ eq(2, eval("line('.')")) -- cursor is in the middle
feed_command('vsplit')
- eq(2, eval("line('.')")) -- cursor stays where we put it
+ eq(2, eval("line('.')")) -- cursor stays where we put it
feed_command('split')
- eq(2, eval("line('.')")) -- cursor stays where we put it
+ eq(2, eval("line('.')")) -- cursor stays where we put it
end)
it('Enter/Leave does not increment jumplist #3723', function()
feed_command('terminal')
local function enter_and_leave()
- local lines_before = funcs.line('$')
+ local lines_before = fn.line('$')
-- Create a new line (in the shell). For a normal buffer this
-- increments the jumplist; for a terminal-buffer it should not. #3723
feed('i')
@@ -86,44 +91,44 @@ describe(':terminal', function()
poke_eventloop()
-- Wait for >=1 lines to be created.
retry(nil, 4000, function()
- ok(funcs.line('$') > lines_before)
+ ok(fn.line('$') > lines_before)
end)
end
enter_and_leave()
enter_and_leave()
enter_and_leave()
- ok(funcs.line('$') > 6) -- Verify assumption.
- local jumps = funcs.split(funcs.execute('jumps'), '\n')
+ ok(fn.line('$') > 6) -- Verify assumption.
+ local jumps = fn.split(fn.execute('jumps'), '\n')
eq(' jump line col file/text', jumps[1])
eq(3, #jumps)
end)
it('nvim_get_mode() in :terminal', function()
command('terminal')
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
feed('i')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
feed([[<C-\><C-N>]])
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
end)
it(':stopinsert RPC request exits terminal-mode #7807', function()
command('terminal')
feed('i[tui] insert-mode')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
command('stopinsert')
- feed('<Ignore>') -- Add input to separate two RPC requests
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ feed('<Ignore>') -- Add input to separate two RPC requests
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
end)
- it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
+ it(":stopinsert in normal mode doesn't break insert mode #9889", function()
command('terminal')
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
command('stopinsert')
- feed('<Ignore>') -- Add input to separate two RPC requests
- eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ feed('<Ignore>') -- Add input to separate two RPC requests
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
feed('a')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
end)
it('switching to terminal buffer in Insert mode goes to Terminal mode #7164', function()
@@ -134,77 +139,73 @@ describe(':terminal', function()
command('autocmd InsertLeave * let g:events += ["InsertLeave"]')
command('autocmd TermEnter * let g:events += ["TermEnter"]')
command('inoremap <F2> <Cmd>wincmd p<CR>')
- eq({ blocking=false, mode='i' }, nvim('get_mode'))
+ eq({ blocking = false, mode = 'i' }, api.nvim_get_mode())
feed('<F2>')
- eq({ blocking=false, mode='t' }, nvim('get_mode'))
- eq({'InsertLeave', 'TermEnter'}, eval('g:events'))
+ eq({ blocking = false, mode = 't' }, api.nvim_get_mode())
+ eq({ 'InsertLeave', 'TermEnter' }, eval('g:events'))
+ end)
+
+ it('switching to terminal buffer immediately after :stopinsert #27031', function()
+ command('terminal')
+ command('vnew')
+ feed('i')
+ eq({ blocking = false, mode = 'i' }, api.nvim_get_mode())
+ command('stopinsert | wincmd p')
+ eq({ blocking = false, mode = 'nt' }, api.nvim_get_mode())
end)
end)
-describe(':terminal (with fake shell)', function()
+local function test_terminal_with_fake_shell(backslash)
+ -- shell-test.c is a fake shell that prints its arguments and exits.
+ local shell_path = testprg('shell-test')
+ if backslash then
+ shell_path = shell_path:gsub('/', [[\]])
+ end
+
local screen
before_each(function()
clear()
screen = Screen.new(50, 4)
- screen:attach({rgb=false})
- -- shell-test.c is a fake shell that prints its arguments and exits.
- nvim('set_option_value', 'shell', testprg('shell-test'), {})
- nvim('set_option_value', 'shellcmdflag', 'EXE', {})
- nvim('set_option_value', 'shellxquote', '', {})
+ screen:attach({ rgb = false })
+ api.nvim_set_option_value('shell', shell_path, {})
+ api.nvim_set_option_value('shellcmdflag', 'EXE', {})
+ api.nvim_set_option_value('shellxquote', '', {}) -- win: avoid extra quotes
end)
- -- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints
- -- the {cmd} and exits immediately.
- -- When no argument is given and the exit code is zero, the terminal buffer
- -- closes automatically.
- local function terminal_with_fake_shell(cmd)
- feed_command("terminal "..(cmd and cmd or ""))
- end
-
it('with no argument, acts like termopen()', function()
- skip(is_os('win'))
- -- Use the EXIT subcommand to end the process with a non-zero exit code to
- -- prevent the buffer from closing automatically
- nvim('set_option_value', 'shellcmdflag', 'EXIT', {})
- terminal_with_fake_shell(1)
- retry(nil, 4 * screen.timeout, function()
+ command('autocmd! nvim_terminal TermClose')
+ feed_command('terminal')
screen:expect([[
- ^ |
- [Process exited 1] |
+ ^ready $ |
+ [Process exited 0] |
|
- :terminal 1 |
+ :terminal |
]])
- end)
end)
it("with no argument, and 'shell' is set to empty string", function()
- nvim('set_option_value', 'shell', '', {})
- terminal_with_fake_shell()
+ api.nvim_set_option_value('shell', '', {})
+ feed_command('terminal')
screen:expect([[
^ |
- ~ |
- ~ |
+ ~ |*2
E91: 'shell' option is empty |
]])
end)
it("with no argument, but 'shell' has arguments, acts like termopen()", function()
- skip(is_os('win'))
- nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {})
- terminal_with_fake_shell()
+ api.nvim_set_option_value('shell', shell_path .. ' INTERACT', {})
+ feed_command('terminal')
screen:expect([[
- ^jeff $ |
- [Process exited 0] |
- |
+ ^interact $ |
+ |*2
:terminal |
]])
end)
it('executes a given command through the shell', function()
- skip(is_os('win'))
- command('set shellxquote=') -- win: avoid extra quotes
- terminal_with_fake_shell('echo hi')
+ feed_command('terminal echo hi')
screen:expect([[
^ready $ echo hi |
|
@@ -214,10 +215,8 @@ describe(':terminal (with fake shell)', function()
end)
it("executes a given command through the shell, when 'shell' has arguments", function()
- skip(is_os('win'))
- nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {})
- command('set shellxquote=') -- win: avoid extra quotes
- terminal_with_fake_shell('echo hi')
+ api.nvim_set_option_value('shell', shell_path .. ' -t jeff', {})
+ feed_command('terminal echo hi')
screen:expect([[
^jeff $ echo hi |
|
@@ -227,9 +226,7 @@ describe(':terminal (with fake shell)', function()
end)
it('allows quotes and slashes', function()
- skip(is_os('win'))
- command('set shellxquote=') -- win: avoid extra quotes
- terminal_with_fake_shell([[echo 'hello' \ "world"]])
+ feed_command([[terminal echo 'hello' \ "world"]])
screen:expect([[
^ready $ echo 'hello' \ "world" |
|
@@ -242,38 +239,39 @@ describe(':terminal (with fake shell)', function()
source([[
autocmd BufNew * set shell=foo
terminal]])
- -- Verify that BufNew actually fired (else the test is invalid).
+ -- Verify that BufNew actually fired (else the test is invalid).
eq('foo', eval('&shell'))
end)
it('ignores writes if the backing stream closes', function()
- terminal_with_fake_shell()
- feed('iiXXXXXXX')
- poke_eventloop()
- -- Race: Though the shell exited (and streams were closed by SIGCHLD
- -- handler), :terminal cleanup is pending on the main-loop.
- -- This write should be ignored (not crash, #5445).
- feed('iiYYYYYYY')
- assert_alive()
+ command('autocmd! nvim_terminal TermClose')
+ feed_command('terminal')
+ feed('iiXXXXXXX')
+ poke_eventloop()
+ -- Race: Though the shell exited (and streams were closed by SIGCHLD
+ -- handler), :terminal cleanup is pending on the main-loop.
+ -- This write should be ignored (not crash, #5445).
+ feed('iiYYYYYYY')
+ assert_alive()
end)
it('works with findfile()', function()
+ command('autocmd! nvim_terminal TermClose')
feed_command('terminal')
- eq('term://', string.match(eval('bufname("%")'), "^term://"))
+ eq('term://', string.match(eval('bufname("%")'), '^term://'))
eq('scripts/shadacat.py', eval('findfile("scripts/shadacat.py", ".")'))
end)
it('works with :find', function()
- skip(is_os('win'))
- nvim('set_option_value', 'shellcmdflag', 'EXIT', {})
- terminal_with_fake_shell(1)
+ command('autocmd! nvim_terminal TermClose')
+ feed_command('terminal')
screen:expect([[
- ^ |
- [Process exited 1] |
+ ^ready $ |
+ [Process exited 0] |
|
- :terminal 1 |
+ :terminal |
]])
- eq('term://', string.match(eval('bufname("%")'), "^term://"))
+ eq('term://', string.match(eval('bufname("%")'), '^term://'))
feed([[<C-\><C-N>]])
feed_command([[find */shadacat.py]])
if is_os('win') then
@@ -284,19 +282,15 @@ describe(':terminal (with fake shell)', function()
end)
it('works with gf', function()
- skip(is_os('win'))
- command('set shellxquote=') -- win: avoid extra quotes
- terminal_with_fake_shell([[echo "scripts/shadacat.py"]])
- retry(nil, 4 * screen.timeout, function()
+ feed_command([[terminal echo "scripts/shadacat.py"]])
screen:expect([[
^ready $ echo "scripts/shadacat.py" |
|
[Process exited 0] |
:terminal echo "scripts/shadacat.py" |
]])
- end)
feed([[<C-\><C-N>]])
- eq('term://', string.match(eval('bufname("%")'), "^term://"))
+ eq('term://', string.match(eval('bufname("%")'), '^term://'))
feed([[ggf"lgf]])
eq('scripts/shadacat.py', eval('bufname("%")'))
end)
@@ -311,4 +305,29 @@ describe(':terminal (with fake shell)', function()
terminal]])
end
end)
+
+ describe('exit does not have long delay #27615', function()
+ for _, ut in ipairs({ 5, 50, 500, 5000, 50000, 500000 }) do
+ it(('with updatetime=%d'):format(ut), function()
+ api.nvim_set_option_value('updatetime', ut, {})
+ api.nvim_set_option_value('shellcmdflag', 'EXIT', {})
+ feed_command('terminal 42')
+ screen:expect([[
+ ^ |
+ [Process exited 42] |
+ |
+ :terminal 42 |
+ ]])
+ end)
+ end
+ end)
+end
+
+describe(':terminal (with fake shell)', function()
+ test_terminal_with_fake_shell(false)
+ if is_os('win') then
+ describe("when 'shell' uses backslashes", function()
+ test_terminal_with_fake_shell(true)
+ end)
+ end
end)
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index 62d3dd67a3..05db1b3c8c 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -5,11 +5,12 @@ local helpers = require('test.functional.helpers')(nil)
local Screen = require('test.functional.ui.screen')
local testprg = helpers.testprg
local exec_lua = helpers.exec_lua
-local nvim = helpers.nvim
+local api = helpers.api
+local nvim_prog = helpers.nvim_prog
local function feed_data(data)
if type(data) == 'table' then
- data = table.concat(data, '\n')
+ data = table.concat(data, '\n')
end
exec_lua('vim.api.nvim_chan_send(vim.b.terminal_job_id, ...)', data)
end
@@ -20,7 +21,7 @@ end
local function make_lua_executor(session)
return function(code, ...)
- local status, rv = session:request('nvim_exec_lua', code, {...})
+ local status, rv = session:request('nvim_exec_lua', code, { ... })
if not status then
session:stop()
error(rv[2])
@@ -32,76 +33,108 @@ end
-- some helpers for controlling the terminal. the codes were taken from
-- infocmp xterm-256color which is less what libvterm understands
-- civis/cnorm
-local function hide_cursor() feed_termcode('[?25l') end
-local function show_cursor() feed_termcode('[?25h') end
+local function hide_cursor()
+ feed_termcode('[?25l')
+end
+local function show_cursor()
+ feed_termcode('[?25h')
+end
-- smcup/rmcup
-local function enter_altscreen() feed_termcode('[?1049h') end
-local function exit_altscreen() feed_termcode('[?1049l') end
+local function enter_altscreen()
+ feed_termcode('[?1049h')
+end
+local function exit_altscreen()
+ feed_termcode('[?1049l')
+end
-- character attributes
-local function set_fg(num) feed_termcode('[38;5;'..num..'m') end
-local function set_bg(num) feed_termcode('[48;5;'..num..'m') end
-local function set_bold() feed_termcode('[1m') end
-local function set_italic() feed_termcode('[3m') end
-local function set_underline() feed_termcode('[4m') end
-local function set_underdouble() feed_termcode('[4:2m') end
-local function set_undercurl() feed_termcode('[4:3m') end
-local function set_strikethrough() feed_termcode('[9m') end
-local function clear_attrs() feed_termcode('[0;10m') end
+local function set_fg(num)
+ feed_termcode('[38;5;' .. num .. 'm')
+end
+local function set_bg(num)
+ feed_termcode('[48;5;' .. num .. 'm')
+end
+local function set_bold()
+ feed_termcode('[1m')
+end
+local function set_italic()
+ feed_termcode('[3m')
+end
+local function set_underline()
+ feed_termcode('[4m')
+end
+local function set_underdouble()
+ feed_termcode('[4:2m')
+end
+local function set_undercurl()
+ feed_termcode('[4:3m')
+end
+local function set_strikethrough()
+ feed_termcode('[9m')
+end
+local function clear_attrs()
+ feed_termcode('[0;10m')
+end
-- mouse
-local function enable_mouse() feed_termcode('[?1002h') end
-local function disable_mouse() feed_termcode('[?1002l') end
+local function enable_mouse()
+ feed_termcode('[?1002h')
+end
+local function disable_mouse()
+ feed_termcode('[?1002l')
+end
-local default_command = '["'..testprg('tty-test')..'"]'
+local default_command = { testprg('tty-test') }
-local function screen_setup(extra_rows, command, cols, opts)
+local function screen_setup(extra_rows, command, cols, env, screen_opts)
extra_rows = extra_rows and extra_rows or 0
command = command and command or default_command
cols = cols and cols or 50
- nvim('command', 'highlight TermCursor cterm=reverse')
- nvim('command', 'highlight TermCursorNC ctermbg=11')
+ api.nvim_command('highlight TermCursor cterm=reverse')
+ api.nvim_command('highlight TermCursorNC ctermbg=11')
local screen = Screen.new(cols, 7 + extra_rows)
screen:set_default_attr_ids({
- [1] = {reverse = true}, -- focused cursor
- [2] = {background = 11}, -- unfocused cursor
- [3] = {bold = true},
- [4] = {foreground = 12},
- [5] = {bold = true, reverse = true},
- -- 6 was a duplicate item
- [7] = {foreground = 130},
- [8] = {foreground = 15, background = 1}, -- error message
- [9] = {foreground = 4},
- [10] = {foreground = 121}, -- "Press ENTER" in embedded :terminal session.
- [11] = {foreground = tonumber('0x00000b')},
- [12] = {underline = true},
- [13] = {underline = true, reverse = true},
- [14] = {underline = true, reverse = true, bold = true},
- [15] = {underline = true, foreground = 12},
+ [1] = { reverse = true }, -- focused cursor
+ [2] = { background = 11 }, -- unfocused cursor
+ [3] = { bold = true },
+ [4] = { foreground = 12 }, -- NonText in :terminal session
+ [5] = { bold = true, reverse = true },
+ [6] = { foreground = 81 }, -- SpecialKey in :terminal session
+ [7] = { foreground = 130 }, -- LineNr in host session
+ [8] = { foreground = 15, background = 1 }, -- ErrorMsg in :terminal session
+ [9] = { foreground = 4 },
+ [10] = { foreground = 121 }, -- MoreMsg in :terminal session
+ [11] = { foreground = 11 }, -- LineNr in :terminal session
+ [12] = { underline = true },
+ [13] = { underline = true, reverse = true },
+ [14] = { underline = true, reverse = true, bold = true },
+ [15] = { underline = true, foreground = 12 },
+ [16] = { background = 248, foreground = 0 }, -- Visual in :terminal session
})
- screen:attach(opts or {rgb=false})
+ screen:attach(screen_opts or { rgb = false })
- nvim('command', 'enew | call termopen('..command..')')
- nvim('input', '<CR>')
- local vim_errmsg = nvim('eval', 'v:errmsg')
- if vim_errmsg and "" ~= vim_errmsg then
+ api.nvim_command('enew')
+ api.nvim_call_function('termopen', { command, env and { env = env } or nil })
+ api.nvim_input('<CR>')
+ local vim_errmsg = api.nvim_eval('v:errmsg')
+ if vim_errmsg and '' ~= vim_errmsg then
error(vim_errmsg)
end
- nvim('command', 'setlocal scrollback=10')
- nvim('command', 'startinsert')
- nvim('input', '<Ignore>') -- Add input to separate two RPC requests
+ api.nvim_command('setlocal scrollback=10')
+ api.nvim_command('startinsert')
+ api.nvim_input('<Ignore>') -- Add input to separate two RPC requests
-- tty-test puts the terminal into raw mode and echoes input. Tests work by
-- feeding termcodes to control the display and asserting by screen:expect.
- if command == default_command and opts == nil then
+ if command == default_command and screen_opts == nil then
-- Wait for "tty ready" to be printed before each test or the terminal may
-- still be in canonical mode (will echo characters for example).
local empty_line = (' '):rep(cols)
local expected = {
- 'tty ready'..(' '):rep(cols - 9),
- '{1: }' ..(' '):rep(cols - 1),
+ 'tty ready' .. (' '):rep(cols - 9),
+ '{1: }' .. (' '):rep(cols - 1),
empty_line,
empty_line,
empty_line,
@@ -112,16 +145,28 @@ local function screen_setup(extra_rows, command, cols, opts)
end
table.insert(expected, '{3:-- TERMINAL --}' .. ((' '):rep(cols - 14)))
- screen:expect(table.concat(expected, '|\n')..'|')
+ screen:expect(table.concat(expected, '|\n') .. '|')
else
-- This eval also acts as a poke_eventloop().
- if 0 == nvim('eval', "exists('b:terminal_job_id')") then
- error("terminal job failed to start")
+ if 0 == api.nvim_eval("exists('b:terminal_job_id')") then
+ error('terminal job failed to start')
end
end
return screen
end
+local function setup_child_nvim(args, opts)
+ opts = opts or {}
+ local argv = { nvim_prog, unpack(args) }
+
+ local env = opts.env or {}
+ if not env.VIMRUNTIME then
+ env.VIMRUNTIME = os.getenv('VIMRUNTIME')
+ end
+
+ return screen_setup(0, argv, opts.cols, env)
+end
+
return {
feed_data = feed_data,
feed_termcode = feed_termcode,
@@ -141,5 +186,6 @@ return {
clear_attrs = clear_attrs,
enable_mouse = enable_mouse,
disable_mouse = disable_mouse,
- screen_setup = screen_setup
+ screen_setup = screen_setup,
+ setup_child_nvim = setup_child_nvim,
}
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua
index 2ac45771d4..ec057c6766 100644
--- a/test/functional/terminal/highlight_spec.lua
+++ b/test/functional/terminal/highlight_spec.lua
@@ -1,11 +1,12 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
-local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
+local feed, clear = helpers.feed, helpers.clear
+local api = helpers.api
local testprg, command = helpers.testprg, helpers.command
local nvim_prog_abs = helpers.nvim_prog_abs
local eq, eval = helpers.eq, helpers.eval
-local funcs = helpers.funcs
+local fn = helpers.fn
local nvim_set = helpers.nvim_set
local is_os = helpers.is_os
local skip = helpers.skip
@@ -17,30 +18,27 @@ describe(':terminal highlight', function()
clear()
screen = Screen.new(50, 7)
screen:set_default_attr_ids({
- [1] = {foreground = 45},
- [2] = {background = 46},
- [3] = {foreground = 45, background = 46},
- [4] = {bold = true, italic = true, underline = true, strikethrough = true},
- [5] = {bold = true},
- [6] = {foreground = 12},
- [7] = {bold = true, reverse = true},
- [8] = {background = 11},
- [9] = {foreground = 130},
- [10] = {reverse = true},
- [11] = {background = 11},
- [12] = {bold = true, underdouble = true},
- [13] = {italic = true, undercurl = true},
+ [1] = { foreground = 45 },
+ [2] = { background = 46 },
+ [3] = { foreground = 45, background = 46 },
+ [4] = { bold = true, italic = true, underline = true, strikethrough = true },
+ [5] = { bold = true },
+ [6] = { foreground = 12 },
+ [7] = { bold = true, reverse = true },
+ [8] = { background = 11 },
+ [9] = { foreground = 130 },
+ [10] = { reverse = true },
+ [11] = { background = 11 },
+ [12] = { bold = true, underdouble = true },
+ [13] = { italic = true, undercurl = true },
})
- screen:attach({rgb=false})
+ screen:attach({ rgb = false })
command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
feed('i')
screen:expect([[
tty ready |
{10: } |
- |
- |
- |
- |
+ |*4
{5:-- TERMINAL --} |
]])
end)
@@ -64,10 +62,7 @@ describe(':terminal highlight', function()
screen:expect(sub([[
tty ready |
{NUM:text}text{10: } |
- |
- |
- |
- |
+ |*4
{5:-- TERMINAL --} |
]]))
end
@@ -79,7 +74,7 @@ describe(':terminal highlight', function()
pass_attrs()
local lines = {}
for i = 1, 8 do
- table.insert(lines, 'line'..tostring(i))
+ table.insert(lines, 'line' .. tostring(i))
end
table.insert(lines, '')
thelpers.feed_data(lines)
@@ -106,8 +101,12 @@ describe(':terminal highlight', function()
end)
end
- descr('foreground', 1, function() thelpers.set_fg(45) end)
- descr('background', 2, function() thelpers.set_bg(46) end)
+ descr('foreground', 1, function()
+ thelpers.set_fg(45)
+ end)
+ descr('background', 2, function()
+ thelpers.set_bg(46)
+ end)
descr('foreground and background', 3, function()
thelpers.set_fg(45)
thelpers.set_bg(46)
@@ -133,20 +132,41 @@ it(':terminal highlight has lower precedence than editor #9964', function()
local screen = Screen.new(30, 4)
screen:set_default_attr_ids({
-- "Normal" highlight emitted by the child nvim process.
- N_child = {foreground = tonumber('0x4040ff'), background = tonumber('0xffff40'), fg_indexed=true, bg_indexed=true},
+ N_child = {
+ foreground = tonumber('0x4040ff'),
+ background = tonumber('0xffff40'),
+ fg_indexed = true,
+ bg_indexed = true,
+ },
-- "Search" highlight in the parent nvim process.
- S = {background = Screen.colors.Green, italic = true, foreground = Screen.colors.Red},
+ S = { background = Screen.colors.Green, italic = true, foreground = Screen.colors.Red },
-- "Question" highlight in the parent nvim process.
-- note: bg is indexed as it comes from the (cterm) child, while fg isn't as it comes from (rgb) parent
- Q = {background = tonumber('0xffff40'), bold = true, foreground = Screen.colors.SeaGreen4, bg_indexed=true},
+ Q = {
+ background = tonumber('0xffff40'),
+ bold = true,
+ foreground = Screen.colors.SeaGreen4,
+ bg_indexed = true,
+ },
})
- screen:attach({rgb=true})
+ screen:attach({ rgb = true })
-- Child nvim process in :terminal (with cterm colors).
- funcs.termopen({
- nvim_prog_abs(), '-n', '-u', 'NORC', '-i', 'NONE', '--cmd', nvim_set,
+ fn.termopen({
+ nvim_prog_abs(),
+ '-n',
+ '-u',
+ 'NORC',
+ '-i',
+ 'NONE',
+ '--cmd',
+ nvim_set .. ' notermguicolors',
'+hi Normal ctermfg=Blue ctermbg=Yellow',
'+norm! ichild nvim',
'+norm! oline 2',
+ }, {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+ },
})
screen:expect([[
{N_child:^child nvim }|
@@ -179,10 +199,10 @@ describe(':terminal highlight forwarding', function()
screen = Screen.new(50, 7)
screen:set_rgb_cterm(true)
screen:set_default_attr_ids({
- [1] = {{reverse = true}, {reverse = true}},
- [2] = {{bold = true}, {bold = true}},
- [3] = {{fg_indexed = true, foreground = tonumber('0xe0e000')}, {foreground = 3}},
- [4] = {{foreground = tonumber('0xff8000')}, {}},
+ [1] = { { reverse = true }, { reverse = true } },
+ [2] = { { bold = true }, { bold = true } },
+ [3] = { { fg_indexed = true, foreground = tonumber('0xe0e000') }, { foreground = 3 } },
+ [4] = { { foreground = tonumber('0xff8000') }, {} },
})
screen:attach()
command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
@@ -190,10 +210,7 @@ describe(':terminal highlight forwarding', function()
screen:expect([[
tty ready |
{1: } |
- |
- |
- |
- |
+ |*4
{2:-- TERMINAL --} |
]])
end)
@@ -206,19 +223,17 @@ describe(':terminal highlight forwarding', function()
thelpers.feed_data('color')
thelpers.clear_attrs()
thelpers.feed_data('text')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tty ready |
{3:text}{4:color}text{1: } |
- |
- |
- |
- |
+ |*4
{2:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end)
end)
-
describe(':terminal highlight with custom palette', function()
local screen
@@ -226,26 +241,23 @@ describe(':terminal highlight with custom palette', function()
clear()
screen = Screen.new(50, 7)
screen:set_default_attr_ids({
- [1] = {foreground = tonumber('0x123456')}, -- no fg_indexed when overridden
- [2] = {foreground = 12},
- [3] = {bold = true, reverse = true},
- [5] = {background = 11},
- [6] = {foreground = 130},
- [7] = {reverse = true},
- [8] = {background = 11},
- [9] = {bold = true},
+ [1] = { foreground = tonumber('0x123456') }, -- no fg_indexed when overridden
+ [2] = { foreground = 12 },
+ [3] = { bold = true, reverse = true },
+ [5] = { background = 11 },
+ [6] = { foreground = 130 },
+ [7] = { reverse = true },
+ [8] = { background = 11 },
+ [9] = { bold = true },
})
- screen:attach({rgb=true})
- nvim('set_var', 'terminal_color_3', '#123456')
+ screen:attach({ rgb = true })
+ api.nvim_set_var('terminal_color_3', '#123456')
command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
feed('i')
screen:expect([[
tty ready |
{7: } |
- |
- |
- |
- |
+ |*4
{9:-- TERMINAL --} |
]])
end)
@@ -259,10 +271,7 @@ describe(':terminal highlight with custom palette', function()
screen:expect([[
tty ready |
{1:text}text{7: } |
- |
- |
- |
- |
+ |*4
{9:-- TERMINAL --} |
]])
end)
@@ -275,35 +284,37 @@ describe('synIDattr()', function()
screen = Screen.new(50, 7)
command('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black')
-- Salmon #fa8072 Maroon #800000
- command('highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon cterm=strikethrough gui=strikethrough')
+ command(
+ 'highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon cterm=strikethrough gui=strikethrough'
+ )
end)
it('returns cterm-color if RGB-capable UI is _not_ attached', function()
eq('252', eval('synIDattr(hlID("Normal"), "fg")'))
eq('252', eval('synIDattr(hlID("Normal"), "fg#")'))
- eq('', eval('synIDattr(hlID("Normal"), "bg")'))
- eq('', eval('synIDattr(hlID("Normal"), "bg#")'))
- eq('79', eval('synIDattr(hlID("Keyword"), "fg")'))
- eq('79', eval('synIDattr(hlID("Keyword"), "fg#")'))
- eq('', eval('synIDattr(hlID("Keyword"), "sp")'))
- eq('', eval('synIDattr(hlID("Keyword"), "sp#")'))
+ eq('', eval('synIDattr(hlID("Normal"), "bg")'))
+ eq('', eval('synIDattr(hlID("Normal"), "bg#")'))
+ eq('79', eval('synIDattr(hlID("Keyword"), "fg")'))
+ eq('79', eval('synIDattr(hlID("Keyword"), "fg#")'))
+ eq('', eval('synIDattr(hlID("Keyword"), "sp")'))
+ eq('', eval('synIDattr(hlID("Keyword"), "sp#")'))
end)
it('returns gui-color if "gui" arg is passed', function()
- eq('Black', eval('synIDattr(hlID("Normal"), "bg", "gui")'))
+ eq('Black', eval('synIDattr(hlID("Normal"), "bg", "gui")'))
eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp", "gui")'))
end)
it('returns gui-color if RGB-capable UI is attached', function()
- screen:attach({rgb=true})
+ screen:attach({ rgb = true })
eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")'))
- eq('Black', eval('synIDattr(hlID("Normal"), "bg")'))
- eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")'))
- eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp")'))
+ eq('Black', eval('synIDattr(hlID("Normal"), "bg")'))
+ eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")'))
+ eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp")'))
end)
it('returns #RRGGBB value for fg#/bg#/sp#', function()
- screen:attach({rgb=true})
+ screen:attach({ rgb = true })
eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")'))
eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")'))
eq('#fa8072', eval('synIDattr(hlID("Keyword"), "fg#")'))
@@ -311,19 +322,24 @@ describe('synIDattr()', function()
end)
it('returns color number if non-GUI', function()
- screen:attach({rgb=false})
+ screen:attach({ rgb = false })
eq('252', eval('synIDattr(hlID("Normal"), "fg")'))
eq('79', eval('synIDattr(hlID("Keyword"), "fg")'))
end)
it('returns "1" if group has given highlight attribute', function()
local hl_attrs = {
- 'underline', 'undercurl', 'underdouble', 'underdotted', 'underdashed', 'strikethrough'
+ 'underline',
+ 'undercurl',
+ 'underdouble',
+ 'underdotted',
+ 'underdashed',
+ 'strikethrough',
}
- for _,hl_attr in ipairs(hl_attrs) do
+ for _, hl_attr in ipairs(hl_attrs) do
local context = 'using ' .. hl_attr .. ' attr'
command('highlight Keyword cterm=' .. hl_attr .. ' gui=' .. hl_attr)
- eq('', eval('synIDattr(hlID("Normal"), "'.. hl_attr .. '")'), context)
+ eq('', eval('synIDattr(hlID("Normal"), "' .. hl_attr .. '")'), context)
eq('1', eval('synIDattr(hlID("Keyword"), "' .. hl_attr .. '")'), context)
eq('1', eval('synIDattr(hlID("Keyword"), "' .. hl_attr .. '", "gui")'), context)
end
@@ -340,14 +356,10 @@ describe('fg/bg special colors', function()
end)
it('resolve to "Normal" values', function()
- eq(eval('synIDattr(hlID("Normal"), "bg")'),
- eval('synIDattr(hlID("Visual"), "fg")'))
- eq(eval('synIDattr(hlID("Normal"), "bg#")'),
- eval('synIDattr(hlID("Visual"), "fg#")'))
- eq(eval('synIDattr(hlID("Normal"), "fg")'),
- eval('synIDattr(hlID("Visual"), "bg")'))
- eq(eval('synIDattr(hlID("Normal"), "fg#")'),
- eval('synIDattr(hlID("Visual"), "bg#")'))
+ eq(eval('synIDattr(hlID("Normal"), "bg")'), eval('synIDattr(hlID("Visual"), "fg")'))
+ eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "fg#")'))
+ eq(eval('synIDattr(hlID("Normal"), "fg")'), eval('synIDattr(hlID("Visual"), "bg")'))
+ eq(eval('synIDattr(hlID("Normal"), "fg#")'), eval('synIDattr(hlID("Visual"), "bg#")'))
eq('bg', eval('synIDattr(hlID("Visual"), "fg", "gui")'))
eq('bg', eval('synIDattr(hlID("Visual"), "fg#", "gui")'))
eq('fg', eval('synIDattr(hlID("Visual"), "bg", "gui")'))
@@ -357,23 +369,20 @@ describe('fg/bg special colors', function()
end)
it('resolve to "Normal" values in RGB-capable UI', function()
- screen:attach({rgb=true})
+ screen:attach({ rgb = true })
eq('bg', eval('synIDattr(hlID("Visual"), "fg")'))
- eq(eval('synIDattr(hlID("Normal"), "bg#")'),
- eval('synIDattr(hlID("Visual"), "fg#")'))
+ eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "fg#")'))
eq('fg', eval('synIDattr(hlID("Visual"), "bg")'))
- eq(eval('synIDattr(hlID("Normal"), "fg#")'),
- eval('synIDattr(hlID("Visual"), "bg#")'))
+ eq(eval('synIDattr(hlID("Normal"), "fg#")'), eval('synIDattr(hlID("Visual"), "bg#")'))
eq('bg', eval('synIDattr(hlID("Visual"), "sp")'))
- eq(eval('synIDattr(hlID("Normal"), "bg#")'),
- eval('synIDattr(hlID("Visual"), "sp#")'))
+ eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "sp#")'))
end)
it('resolve after the "Normal" group is modified', function()
- screen:attach({rgb=true})
+ screen:attach({ rgb = true })
local new_guibg = '#282c34'
local new_guifg = '#abb2bf'
- command('highlight Normal guifg='..new_guifg..' guibg='..new_guibg)
+ command('highlight Normal guifg=' .. new_guifg .. ' guibg=' .. new_guibg)
eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")'))
eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")'))
eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")'))
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index 3291a38e03..0395d5ee16 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval
-local feed, nvim, command = helpers.feed, helpers.nvim, helpers.command
+local feed, api, command = helpers.feed, helpers.api, helpers.command
local feed_data = thelpers.feed_data
local is_os = helpers.is_os
local skip = helpers.skip
@@ -11,14 +11,14 @@ describe(':terminal mouse', function()
before_each(function()
clear()
- nvim('set_option_value', 'statusline', '==========', {})
+ api.nvim_set_option_value('statusline', '==========', {})
command('highlight StatusLine cterm=NONE')
command('highlight StatusLineNC cterm=NONE')
command('highlight VertSplit cterm=NONE')
screen = thelpers.screen_setup()
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)
@@ -243,6 +243,134 @@ describe(':terminal mouse', function()
{3:-- TERMINAL --} |
]])
end)
+
+ it('will lose focus if statusline is clicked', function()
+ command('set laststatus=2')
+ screen:expect([[
+ line29 |
+ line30 |
+ mouse enabled |
+ rows: 5, cols: 50 |
+ {1: } |
+ ========== |
+ {3:-- TERMINAL --} |
+ ]])
+ feed('<LeftMouse><0,5>')
+ screen:expect([[
+ line29 |
+ line30 |
+ mouse enabled |
+ rows: 5, cols: 50 |
+ {2:^ } |
+ ========== |
+ |
+ ]])
+ feed('<LeftDrag><0,4>')
+ screen:expect([[
+ mouse enabled |
+ rows: 5, cols: 50 |
+ rows: 4, cols: 50 |
+ {2:^ } |
+ ========== |
+ |*2
+ ]])
+ end)
+
+ it('will lose focus if right separator is clicked', function()
+ command('rightbelow vnew | wincmd p | startinsert')
+ screen:expect([[
+ line29 │ |
+ line30 │{4:~ }|
+ mouse enabled │{4:~ }|
+ rows: 5, cols: 24 │{4:~ }|
+ {1: } │{4:~ }|
+ ========== ========== |
+ {3:-- TERMINAL --} |
+ ]])
+ feed('<LeftMouse><24,0>')
+ screen:expect([[
+ line29 │ |
+ line30 │{4:~ }|
+ mouse enabled │{4:~ }|
+ rows: 5, cols: 24 │{4:~ }|
+ {2:^ } │{4:~ }|
+ ========== ========== |
+ |
+ ]])
+ feed('<LeftDrag><23,0>')
+ screen:expect([[
+ line30 │ |
+ mouse enabled │{4:~ }|
+ rows: 5, cols: 24 │{4:~ }|
+ rows: 5, cols: 23 │{4:~ }|
+ {2:^ } │{4:~ }|
+ ========== ========== |
+ |
+ ]])
+ end)
+
+ it('will lose focus if winbar/tabline is clicked', function()
+ command('setlocal winbar=WINBAR')
+ screen:expect([[
+ {3:WINBAR }|
+ line29 |
+ line30 |
+ mouse enabled |
+ rows: 5, cols: 50 |
+ {1: } |
+ {3:-- TERMINAL --} |
+ ]])
+ feed('<LeftMouse><0,0>')
+ screen:expect([[
+ {3:WINBAR }|
+ line29 |
+ line30 |
+ mouse enabled |
+ rows: 5, cols: 50 |
+ {2:^ } |
+ |
+ ]])
+ command('set showtabline=2 tabline=TABLINE | startinsert')
+ screen:expect([[
+ {1:TABLINE }|
+ {3:WINBAR }|
+ mouse enabled |
+ rows: 5, cols: 50 |
+ rows: 4, cols: 50 |
+ {1: } |
+ {3:-- TERMINAL --} |
+ ]])
+ feed('<LeftMouse><0,0>')
+ screen:expect([[
+ {1:TABLINE }|
+ {3:WINBAR }|
+ mouse enabled |
+ rows: 5, cols: 50 |
+ rows: 4, cols: 50 |
+ {2:^ } |
+ |
+ ]])
+ command('setlocal winbar= | startinsert')
+ screen:expect([[
+ {1:TABLINE }|
+ mouse enabled |
+ rows: 5, cols: 50 |
+ rows: 4, cols: 50 |
+ rows: 5, cols: 50 |
+ {1: } |
+ {3:-- TERMINAL --} |
+ ]])
+ feed('<LeftMouse><0,0>')
+ screen:expect([[
+ {1:TABLINE }|
+ mouse enabled |
+ rows: 5, cols: 50 |
+ rows: 4, cols: 50 |
+ rows: 5, cols: 50 |
+ {2:^ } |
+ |
+ ]])
+ end)
end)
describe('with a split window and other buffer', function()
@@ -386,7 +514,7 @@ describe(':terminal mouse', function()
end)
it('handles terminal size when switching buffers', function()
- nvim('set_option_value', 'hidden', true, {})
+ api.nvim_set_option_value('hidden', true, {})
feed('<c-\\><c-n><c-w><c-w>')
screen:expect([[
{7: 27 }line │line30 |
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 1e278e4cff..858e23984d 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 api = helpers.api
local feed_data = thelpers.feed_data
local pcall_err = helpers.pcall_err
local exec_lua = helpers.exec_lua
@@ -28,7 +27,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 +58,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 +71,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([[
@@ -84,11 +85,13 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(7, curbuf('line_count'))
+ eq(7, api.nvim_buf_line_count(0))
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 +140,6 @@ describe(':terminal scrollback', function()
end)
end)
-
describe('and height decreased by 1', function()
local function will_hide_top_line()
feed([[<C-\><C-N>]])
@@ -167,7 +169,7 @@ describe(':terminal scrollback', function()
{2:^ } |
|
]])
- eq(8, curbuf('line_count'))
+ eq(8, api.nvim_buf_line_count(0))
feed([[3k]])
screen:expect([[
^line4 |
@@ -184,7 +186,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()
@@ -199,7 +203,7 @@ describe(':terminal scrollback', function()
|
{3:-- TERMINAL --} |
]])
- eq(4, curbuf('line_count'))
+ eq(4, api.nvim_buf_line_count(0))
end
it('will delete the last two empty lines', will_delete_last_two_lines)
@@ -217,7 +221,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(4, curbuf('line_count'))
+ eq(4, api.nvim_buf_line_count(0))
feed('<c-\\><c-n>gg')
screen:expect([[
^tty ready |
@@ -239,7 +243,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 |
@@ -256,14 +260,16 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(7, curbuf('line_count'))
+ eq(7, api.nvim_buf_line_count(0))
end)
describe('and the height is increased by 1', 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([[
@@ -280,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, api.nvim_buf_line_count(0))
screen:try_resize(screen._width, screen._height + 3)
end)
@@ -295,7 +301,7 @@ describe(':terminal scrollback', function()
{1: } |
{3:-- TERMINAL --} |
]])
- eq(9, curbuf('line_count'))
+ eq(9, api.nvim_buf_line_count(0))
feed('<c-\\><c-n>gg')
screen:expect([[
^tty ready |
@@ -335,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, api.nvim_buf_line_count(0))
end)
end)
end)
@@ -347,7 +353,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 |
@@ -362,11 +368,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)
@@ -378,62 +380,71 @@ describe("'scrollback' option", function()
end)
local function set_fake_shell()
- 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)
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
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, {})
+ 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() 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()
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, {})
+ api.nvim_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)
- meths.set_option_value('scrollback', 10, {})
+ retry(nil, nil, function()
+ expect_lines(33, 2)
+ end)
+ api.nvim_set_option_value('scrollback', 10, {})
poke_eventloop()
- 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)
+ api.nvim_set_option_value('scrollback', 10000, {})
+ 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 |
@@ -441,9 +452,11 @@ describe("'scrollback' option", function()
|
${1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
else
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
36: line |
37: line |
38: line |
@@ -451,7 +464,8 @@ describe("'scrollback' option", function()
40: line |
{MATCH:.*}|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end
expect_lines(58)
@@ -465,11 +479,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 |
@@ -478,32 +492,33 @@ 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', {})
+ local scrollback = api.nvim_get_option_value('scrollback', {})
eq(scrollback + term_height, eval('line("$")'))
-- Reduction
scrollback = scrollback - 2
- meths.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.get_option_value('scrollback', {}))
+ eq(10000, api.nvim_get_option_value('scrollback', {}))
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()
command('new')
- eq(-1, meths.get_option_value('scrollback', {}))
+ eq(-1, api.nvim_get_option_value('scrollback', {}))
end)
it(':setlocal in a :terminal buffer', function()
@@ -512,50 +527,49 @@ 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, 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.get_option_value('scrollback', {}))
+ retry(nil, nil, function() -- Fixup happens on refresh, not immediately.
+ 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.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.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.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.get_option_value('scrollback', {}))
+ command('set scrollback=42') -- set global value
+ eq(42, api.nvim_get_option_value('scrollback', {}))
command('terminal')
- eq(42, meths.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.get_option_value('scrollback', {}))
- command('set scrollback<') -- reset to global default
- eq(42, meths.get_option_value('scrollback', {}))
- command('setglobal scrollback=734') -- new global default
- eq(42, meths.get_option_value('scrollback', {})) -- local value did not change
+ eq(99, api.nvim_get_option_value('scrollback', {}))
+ command('set scrollback<') -- reset to global default
+ eq(42, api.nvim_get_option_value('scrollback', {}))
+ command('setglobal scrollback=734') -- new global default
+ eq(42, api.nvim_get_option_value('scrollback', {})) -- local value did not change
command('terminal')
- eq(734, meths.get_option_value('scrollback', {}))
+ eq(734, api.nvim_get_option_value('scrollback', {}))
end)
-
end)
-describe("pending scrollback line handling", function()
+describe('pending scrollback line handling', function()
local screen
before_each(function()
@@ -563,9 +577,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)
@@ -580,41 +594,42 @@ 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()
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 |*4
|
[Process exited 0]{2: } |
{3:-- TERMINAL --} |
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index b17eed00f9..94690524d3 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -20,16 +20,19 @@ local nvim_prog = helpers.nvim_prog
local nvim_set = helpers.nvim_set
local ok = helpers.ok
local read_file = helpers.read_file
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local is_ci = helpers.is_ci
local is_os = helpers.is_os
local new_pipename = helpers.new_pipename
local spawn_argv = helpers.spawn_argv
local set_session = helpers.set_session
local write_file = helpers.write_file
+local eval = helpers.eval
-if helpers.skip(is_os('win')) then return end
+if helpers.skip(is_os('win')) then
+ return
+end
describe('TUI', function()
local screen
@@ -39,14 +42,21 @@ describe('TUI', function()
before_each(function()
clear()
local child_server = new_pipename()
- screen = thelpers.screen_setup(0,
- string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
- nvim_prog, child_server, nvim_set))
+ screen = thelpers.setup_child_nvim({
+ '--listen',
+ child_server,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ nvim_set .. ' notermguicolors laststatus=2 background=dark',
+ '--cmd',
+ 'colorscheme vim',
+ })
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
|
{3:-- TERMINAL --} |
@@ -75,7 +85,7 @@ describe('TUI', function()
it('rapid resize #7572 #7628', function()
helpers.skip(helpers.is_asan(), 'Test extra unstable with ASAN. See #23762')
-- Need buffer rows to provoke the behavior.
- feed_data(":edit test/functional/fixtures/bigfile.txt\n")
+ feed_data(':edit test/functional/fixtures/bigfile.txt\n')
screen:expect([[
{1:0}000;<control>;Cc;0;BN;;;;;N;NULL;;;; |
0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;;; |
@@ -102,21 +112,26 @@ describe('TUI', function()
screen:try_resize(57, 17)
command('call jobresize(b:terminal_job_id, 57, 17)')
retry(nil, nil, function()
- eq({true, 57}, {child_session:request('nvim_win_get_width', 0)})
+ eq({ true, 57 }, { child_session:request('nvim_win_get_width', 0) })
end)
end)
it('accepts resize while pager is active', function()
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
set more
func! ManyErr()
for i in range(20)
echoerr "FAIL ".i
endfor
endfunc
- ]], {})
+ ]],
+ {}
+ )
feed_data(':call ManyErr()\r')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{8:Error detected while processing function ManyErr:} |
{11:line 2:} |
{8:FAIL 0} |
@@ -124,24 +139,27 @@ describe('TUI', function()
{8:FAIL 2} |
{10:-- More --}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
- screen:try_resize(50,10)
- screen:expect{grid=[[
+ screen:try_resize(50, 10)
+ screen:expect {
+ grid = [[
:call ManyErr() |
{8:Error detected while processing function ManyErr:} |
{11:line 2:} |
{8:FAIL 0} |
{8:FAIL 1} |
{8:FAIL 2} |
- |
- |
+ |*2
{10:-- More --}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data('j')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{8:Error detected while processing function ManyErr:} |
{11:line 2:} |
{8:FAIL 0} |
@@ -152,10 +170,12 @@ describe('TUI', function()
{8:FAIL 5} |
{10:-- More --}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
- screen:try_resize(50,7)
- screen:expect{grid=[[
+ screen:try_resize(50, 7)
+ screen:expect {
+ grid = [[
{8:FAIL 1} |
{8:FAIL 2} |
{8:FAIL 3} |
@@ -163,28 +183,34 @@ describe('TUI', function()
{8:FAIL 5} |
{10:-- More --}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
- screen:try_resize(50,5)
- screen:expect{grid=[[
+ screen:try_resize(50, 5)
+ screen:expect {
+ grid = [[
{8:FAIL 3} |
{8:FAIL 4} |
{8:FAIL 5} |
{10:-- More --}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data('g')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
:call ManyErr() |
{8:Error detected while processing function ManyErr:} |
{11:line 2:} |
{10:-- More --}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
- screen:try_resize(50,10)
- screen:expect{grid=[[
+ screen:try_resize(50, 10)
+ screen:expect {
+ grid = [[
:call ManyErr() |
{8:Error detected while processing function ManyErr:} |
{11:line 2:} |
@@ -195,21 +221,19 @@ describe('TUI', function()
{8:FAIL 4} |
{10:-- More --}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data('\003')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*6
{5:[No Name] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end)
it('accepts basic utf-8 input', function()
@@ -238,8 +262,8 @@ describe('TUI', function()
it('interprets leading <Esc> byte as ALT modifier in normal-mode', function()
local keys = 'dfghjkl'
for c in keys:gmatch('.') do
- feed_data(':nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>\r')
- feed_data('\027'..c)
+ feed_data(':nnoremap <a-' .. c .. '> ialt-' .. c .. '<cr><esc>\r')
+ feed_data('\027' .. c)
end
screen:expect([[
alt-j |
@@ -268,9 +292,7 @@ describe('TUI', function()
feed_data('i\022\027j')
screen:expect([[
<M-j>{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
@@ -278,17 +300,19 @@ describe('TUI', function()
end)
it('interprets <Esc>[27u as <Esc>', function()
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
nnoremap <M-;> <Nop>
nnoremap <Esc> AESC<Esc>
nnoremap ; Asemicolon<Esc>
- ]], {})
+ ]],
+ {}
+ )
feed_data('\027[27u;')
screen:expect([[
ESCsemicolo{1:n} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
@@ -302,9 +326,7 @@ describe('TUI', function()
feed_data('i\022\027\000')
screen:expect([[
<M-C-Space>{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
@@ -316,25 +338,25 @@ describe('TUI', function()
feed_data('\022\007') -- ctrl+g
feed_data('\022\022') -- ctrl+v
feed_data('\022\013') -- ctrl+m
- local attrs = screen:get_default_attr_ids()
- attrs[11] = {foreground = 81}
screen:expect([[
- {11:^G^V^M}{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {6:^G^V^M}{1: } |
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
- ]], attrs)
+ ]])
end)
local function test_mouse_wheel(esc)
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
set number nostartofline nowrap mousescroll=hor:1,ver:1
call setline(1, repeat([join(range(10), '----')], 10))
vsplit
- ]], {})
+ ]],
+ {}
+ )
screen:expect([[
{11: 1 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
{11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----|
@@ -348,7 +370,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<65;8;1M')
else
- meths.input_mouse('wheel', 'down', '', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'down', '', 0, 0, 7)
end
screen:expect([[
{11: 2 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
@@ -363,7 +385,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<65;48;1M')
else
- meths.input_mouse('wheel', 'down', '', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'down', '', 0, 0, 47)
end
screen:expect([[
{11: 2 }{1:0}----1----2----3----4│{11: 2 }0----1----2----3----|
@@ -378,7 +400,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<67;8;1M')
else
- meths.input_mouse('wheel', 'right', '', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'right', '', 0, 0, 7)
end
screen:expect([[
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }0----1----2----3----|
@@ -393,7 +415,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<67;48;1M')
else
- meths.input_mouse('wheel', 'right', '', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'right', '', 0, 0, 47)
end
screen:expect([[
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
@@ -408,7 +430,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<69;8;1M')
else
- meths.input_mouse('wheel', 'down', 'S', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 7)
end
screen:expect([[
{11: 5 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
@@ -423,7 +445,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<69;48;1M')
else
- meths.input_mouse('wheel', 'down', 'S', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 47)
end
screen:expect([[
{11: 5 }{1:-}---1----2----3----4-│{11: 5 }----1----2----3----4|
@@ -438,7 +460,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<71;8;1M')
else
- meths.input_mouse('wheel', 'right', 'S', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 7)
end
screen:expect([[
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }----1----2----3----4|
@@ -453,7 +475,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<71;48;1M')
else
- meths.input_mouse('wheel', 'right', 'S', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 47)
end
screen:expect([[
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }5----6----7----8----|
@@ -468,7 +490,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<64;8;1M')
else
- meths.input_mouse('wheel', 'up', '', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'up', '', 0, 0, 7)
end
screen:expect([[
{11: 4 }----6----7----8----9 │{11: 5 }5----6----7----8----|
@@ -483,7 +505,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<64;48;1M')
else
- meths.input_mouse('wheel', 'up', '', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'up', '', 0, 0, 47)
end
screen:expect([[
{11: 4 }----6----7----8----9 │{11: 4 }5----6----7----8----|
@@ -498,7 +520,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<66;8;1M')
else
- meths.input_mouse('wheel', 'left', '', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'left', '', 0, 0, 7)
end
screen:expect([[
{11: 4 }5----6----7----8----9│{11: 4 }5----6----7----8----|
@@ -513,7 +535,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<66;48;1M')
else
- meths.input_mouse('wheel', 'left', '', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'left', '', 0, 0, 47)
end
screen:expect([[
{11: 4 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
@@ -528,7 +550,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<68;8;1M')
else
- meths.input_mouse('wheel', 'up', 'S', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 7)
end
screen:expect([[
{11: 1 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
@@ -543,7 +565,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<68;48;1M')
else
- meths.input_mouse('wheel', 'up', 'S', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 47)
end
screen:expect([[
{11: 1 }5----6----7----8----9│{11: 1 }-5----6----7----8---|
@@ -558,7 +580,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<70;8;1M')
else
- meths.input_mouse('wheel', 'left', 'S', 0, 0, 7)
+ api.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 7)
end
screen:expect([[
{11: 1 }0----1----2----3----4│{11: 1 }-5----6----7----8---|
@@ -573,7 +595,7 @@ describe('TUI', function()
if esc then
feed_data('\027[<70;48;1M')
else
- meths.input_mouse('wheel', 'left', 'S', 0, 0, 47)
+ api.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 47)
end
screen:expect([[
{11: 1 }0----1----2----3----4│{11: 1 }0----1----2----3----|
@@ -597,7 +619,9 @@ describe('TUI', function()
end)
local function test_mouse_popup(esc)
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
call setline(1, 'popup menu test')
set mouse=a mousemodel=popup
@@ -607,11 +631,13 @@ describe('TUI', function()
menu PopUp.baz :let g:menustr = 'baz'<CR>
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
- ]], {})
+ ]],
+ {}
+ )
if esc then
feed_data('\027[<2;5;1M')
else
- meths.input_mouse('right', 'press', '', 0, 0, 4)
+ api.nvim_input_mouse('right', 'press', '', 0, 0, 4)
end
screen:expect([[
{1:p}opup menu test |
@@ -625,13 +651,27 @@ describe('TUI', function()
if esc then
feed_data('\027[<2;5;1m')
else
- meths.input_mouse('right', 'release', '', 0, 0, 4)
+ api.nvim_input_mouse('right', 'release', '', 0, 0, 4)
end
screen:expect_unchanged()
if esc then
+ feed_data('\027[<64;5;1M')
+ else
+ api.nvim_input_mouse('wheel', 'up', '', 0, 0, 4)
+ end
+ screen:expect([[
+ {1:p}opup menu test |
+ {4:~ }{14: foo }{4: }|
+ {4:~ }{13: bar }{4: }|
+ {4:~ }{13: baz }{4: }|
+ {5:[No Name] [+] }|
+ |
+ {3:-- TERMINAL --} |
+ ]])
+ if esc then
feed_data('\027[<35;7;4M')
else
- meths.input_mouse('move', '', '', 0, 3, 6)
+ api.nvim_input_mouse('move', '', '', 0, 3, 6)
end
screen:expect([[
{1:p}opup menu test |
@@ -643,15 +683,27 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
if esc then
+ feed_data('\027[<65;7;4M')
+ else
+ api.nvim_input_mouse('wheel', 'down', '', 0, 3, 6)
+ end
+ screen:expect([[
+ {1:p}opup menu test |
+ {4:~ }{13: foo }{4: }|
+ {4:~ }{14: bar }{4: }|
+ {4:~ }{13: baz }{4: }|
+ {5:[No Name] [+] }|
+ |
+ {3:-- TERMINAL --} |
+ ]])
+ if esc then
feed_data('\027[<0;7;3M')
else
- meths.input_mouse('left', 'press', '', 0, 2, 6)
+ api.nvim_input_mouse('left', 'press', '', 0, 2, 6)
end
screen:expect([[
{1:p}opup menu test |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
:let g:menustr = 'bar' |
{3:-- TERMINAL --} |
@@ -659,18 +711,17 @@ describe('TUI', function()
if esc then
feed_data('\027[<0;7;3m')
else
- meths.input_mouse('left', 'release', '', 0, 2, 6)
+ api.nvim_input_mouse('left', 'release', '', 0, 2, 6)
end
screen:expect_unchanged()
if esc then
feed_data('\027[<2;45;3M')
else
- meths.input_mouse('right', 'press', '', 0, 2, 44)
+ api.nvim_input_mouse('right', 'press', '', 0, 2, 44)
end
screen:expect([[
{1:p}opup menu test |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{4:~ }{13: foo }{4: }|
{5:[No Name] [+] }{13: bar }{5: }|
:let g:menustr = 'bar' {13: baz } |
@@ -679,12 +730,11 @@ describe('TUI', function()
if esc then
feed_data('\027[<34;48;6M')
else
- meths.input_mouse('right', 'drag', '', 0, 5, 47)
+ api.nvim_input_mouse('right', 'drag', '', 0, 5, 47)
end
screen:expect([[
{1:p}opup menu test |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{4:~ }{13: foo }{4: }|
{5:[No Name] [+] }{13: bar }{5: }|
:let g:menustr = 'bar' {14: baz } |
@@ -693,13 +743,11 @@ describe('TUI', function()
if esc then
feed_data('\027[<2;48;6m')
else
- meths.input_mouse('right', 'release', '', 0, 5, 47)
+ api.nvim_input_mouse('right', 'release', '', 0, 5, 47)
end
screen:expect([[
{1:p}opup menu test |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
:let g:menustr = 'baz' |
{3:-- TERMINAL --} |
@@ -718,78 +766,72 @@ describe('TUI', function()
it('accepts keypad keys from kitty keyboard protocol #19180', function()
feed_data('i')
- feed_data(funcs.nr2char(57399)) -- KP_0
- feed_data(funcs.nr2char(57400)) -- KP_1
- feed_data(funcs.nr2char(57401)) -- KP_2
- feed_data(funcs.nr2char(57402)) -- KP_3
- feed_data(funcs.nr2char(57403)) -- KP_4
- feed_data(funcs.nr2char(57404)) -- KP_5
- feed_data(funcs.nr2char(57405)) -- KP_6
- feed_data(funcs.nr2char(57406)) -- KP_7
- feed_data(funcs.nr2char(57407)) -- KP_8
- feed_data(funcs.nr2char(57408)) -- KP_9
- feed_data(funcs.nr2char(57409)) -- KP_DECIMAL
- feed_data(funcs.nr2char(57410)) -- KP_DIVIDE
- feed_data(funcs.nr2char(57411)) -- KP_MULTIPLY
- feed_data(funcs.nr2char(57412)) -- KP_SUBTRACT
- feed_data(funcs.nr2char(57413)) -- KP_ADD
- feed_data(funcs.nr2char(57414)) -- KP_ENTER
- feed_data(funcs.nr2char(57415)) -- KP_EQUAL
+ feed_data(fn.nr2char(57399)) -- KP_0
+ feed_data(fn.nr2char(57400)) -- KP_1
+ feed_data(fn.nr2char(57401)) -- KP_2
+ feed_data(fn.nr2char(57402)) -- KP_3
+ feed_data(fn.nr2char(57403)) -- KP_4
+ feed_data(fn.nr2char(57404)) -- KP_5
+ feed_data(fn.nr2char(57405)) -- KP_6
+ feed_data(fn.nr2char(57406)) -- KP_7
+ feed_data(fn.nr2char(57407)) -- KP_8
+ feed_data(fn.nr2char(57408)) -- KP_9
+ feed_data(fn.nr2char(57409)) -- KP_DECIMAL
+ feed_data(fn.nr2char(57410)) -- KP_DIVIDE
+ feed_data(fn.nr2char(57411)) -- KP_MULTIPLY
+ feed_data(fn.nr2char(57412)) -- KP_SUBTRACT
+ feed_data(fn.nr2char(57413)) -- KP_ADD
+ feed_data(fn.nr2char(57414)) -- KP_ENTER
+ feed_data(fn.nr2char(57415)) -- KP_EQUAL
screen:expect([[
0123456789./*-+ |
={1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57417)) -- KP_LEFT
+ feed_data(fn.nr2char(57417)) -- KP_LEFT
screen:expect([[
0123456789./*-+ |
{1:=} |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57418)) -- KP_RIGHT
+ feed_data(fn.nr2char(57418)) -- KP_RIGHT
screen:expect([[
0123456789./*-+ |
={1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57419)) -- KP_UP
+ feed_data(fn.nr2char(57419)) -- KP_UP
screen:expect([[
0{1:1}23456789./*-+ |
= |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57420)) -- KP_DOWN
+ feed_data(fn.nr2char(57420)) -- KP_DOWN
screen:expect([[
0123456789./*-+ |
={1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57425)) -- KP_INSERT
+ feed_data(fn.nr2char(57425)) -- KP_INSERT
screen:expect([[
0123456789./*-+ |
={1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- REPLACE --} |
{3:-- TERMINAL --} |
@@ -798,8 +840,7 @@ describe('TUI', function()
screen:expect([[
0123456789./*-+ |
{1:=} |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
@@ -808,8 +849,7 @@ describe('TUI', function()
screen:expect([[
{1:0}123456789./*-+ |
= |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
@@ -818,52 +858,51 @@ describe('TUI', function()
screen:expect([[
0123456789{1:.}/*-+ |
= |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57426)) -- KP_DELETE
+ feed_data(fn.nr2char(57426)) -- KP_DELETE
screen:expect([[
0123456789{1:/}*-+ |
= |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57423)) -- KP_HOME
+ feed_data(fn.nr2char(57423)) -- KP_HOME
screen:expect([[
{1:0}123456789/*-+ |
= |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
- feed_data(funcs.nr2char(57424)) -- KP_END
+ feed_data(fn.nr2char(57424)) -- KP_END
screen:expect([[
0123456789/*-{1:+} |
= |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
tab split
tabnew
highlight Tabline ctermbg=NONE ctermfg=NONE cterm=underline
- ]], {})
+ ]],
+ {}
+ )
screen:expect([[
{12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}|
{1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] }|
|
{3:-- TERMINAL --} |
@@ -882,8 +921,7 @@ describe('TUI', function()
screen:expect([[
{12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}|
{1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] }|
|
{3:-- TERMINAL --} |
@@ -892,20 +930,19 @@ describe('TUI', function()
it('supports Super and Meta modifiers', function()
feed_data('i')
- feed_data('\022\027[106;9u') -- Super + j
- feed_data('\022\027[107;33u') -- Meta + k
- feed_data('\022\027[13;41u') -- Super + Meta + Enter
- feed_data('\022\027[127;48u') -- Shift + Alt + Ctrl + Super + Meta + Backspace
+ feed_data('\022\027[106;9u') -- Super + j
+ feed_data('\022\027[107;33u') -- Meta + k
+ feed_data('\022\027[13;41u') -- Super + Meta + Enter
+ feed_data('\022\027[127;48u') -- Shift + Alt + Ctrl + Super + Meta + Backspace
feed_data('\n')
- feed_data('\022\027[57376;9u') -- Super + F13
- feed_data('\022\027[57377;33u') -- Meta + F14
- feed_data('\022\027[57378;41u') -- Super + Meta + F15
- feed_data('\022\027[57379;48u') -- Shift + Alt + Ctrl + Super + Meta + F16
+ feed_data('\022\027[57376;9u') -- Super + F13
+ feed_data('\022\027[57377;33u') -- Meta + F14
+ feed_data('\022\027[57378;41u') -- Super + Meta + F15
+ feed_data('\022\027[57379;48u') -- Shift + Alt + Ctrl + Super + Meta + F16
screen:expect([[
<D-j><T-k><T-D-CR><M-T-C-S-D-BS> |
<D-F13><T-F14><T-D-F15><M-T-C-S-D-F16>{1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
@@ -917,61 +954,54 @@ describe('TUI', function()
feed_data('i""\027i\027[200~')
screen:expect([[
"{1:"} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
feed_data('pasted from terminal')
- expect_child_buf_lines({'"pasted from terminal"'})
+ expect_child_buf_lines({ '"pasted from terminal"' })
screen:expect([[
"pasted from terminal{1:"} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data('\027[201~') -- End paste.
- feed_data('\027[27u') -- ESC: go to Normal mode.
+ feed_data('\027[201~') -- End paste.
+ feed_data('\027[27u') -- ESC: go to Normal mode.
wait_for_mode('n')
screen:expect([[
"pasted from termina{1:l}" |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
-- Dot-repeat/redo.
feed_data('2.')
- expect_child_buf_lines({'"pasted from terminapasted from terminalpasted from terminall"'})
+ expect_child_buf_lines({ '"pasted from terminapasted from terminalpasted from terminall"' })
screen:expect([[
"pasted from terminapasted from terminalpasted fro|
m termina{1:l}l" |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
]])
-- Undo.
feed_data('u')
- expect_child_buf_lines({'"pasted from terminal"'})
+ expect_child_buf_lines({ '"pasted from terminal"' })
feed_data('u')
- expect_child_buf_lines({'""'})
+ expect_child_buf_lines({ '""' })
feed_data('u')
- expect_child_buf_lines({''})
+ expect_child_buf_lines({ '' })
end)
it('paste: select-mode', function()
feed_data('ithis is line 1\nthis is line 2\nline 3 is here\n\027')
wait_for_mode('n')
- screen:expect{grid=[[
+ screen:expect([[
this is line 1 |
this is line 2 |
line 3 is here |
@@ -979,33 +1009,40 @@ describe('TUI', function()
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
-- Select-mode. Use <C-n> to move down.
feed_data('gg04lgh\14\14')
- wait_for_mode('s')
+ screen:expect([[
+ this{16: is line 1} |
+ {16:this is line 2} |
+ {16:line}{1: }3 is here |
+ |
+ {5:[No Name] [+] }|
+ {3:-- SELECT --} |
+ {3:-- TERMINAL --} |
+ ]])
feed_data('\027[200~')
feed_data('just paste it™')
feed_data('\027[201~')
- screen:expect{grid=[[
+ screen:expect([[
thisjust paste it{1:™}3 is here |
|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
-- Undo.
feed_data('u')
- expect_child_buf_lines{
+ expect_child_buf_lines {
'this is line 1',
'this is line 2',
'line 3 is here',
'',
}
-- Redo.
- feed_data('\18') -- <C-r>
- expect_child_buf_lines{
+ feed_data('\18') -- <C-r>
+ expect_child_buf_lines {
'thisjust paste it™3 is here',
'',
}
@@ -1013,32 +1050,28 @@ describe('TUI', function()
it('paste: terminal mode', function()
if is_ci('github') then
- pending("tty-test complains about not owning the terminal -- actions/runner#241")
+ pending('tty-test complains about not owning the terminal -- actions/runner#241')
end
child_exec_lua('vim.o.statusline="^^^^^^^"')
child_exec_lua('vim.cmd.terminal(...)', testprg('tty-test'))
feed_data('i')
- screen:expect{grid=[[
+ screen:expect([[
tty ready |
{1: } |
- |
- |
+ |*2
{5:^^^^^^^ }|
- {3:-- TERMINAL --} |
- {3:-- TERMINAL --} |
- ]]}
+ {3:-- TERMINAL --} |*2
+ ]])
feed_data('\027[200~')
feed_data('hallo')
feed_data('\027[201~')
- screen:expect{grid=[[
+ screen:expect([[
tty ready |
hallo{1: } |
- |
- |
+ |*2
{5:^^^^^^^ }|
- {3:-- TERMINAL --} |
- {3:-- TERMINAL --} |
- ]]}
+ {3:-- TERMINAL --} |*2
+ ]])
end)
it('paste: normal-mode (+CRLF #10872)', function()
@@ -1046,99 +1079,98 @@ describe('TUI', function()
wait_for_mode('c')
feed_data('\n')
wait_for_mode('n')
- local expected_lf = {'line 1', 'ESC:\027 / CR: \rx'}
- local expected_crlf = {'line 1', 'ESC:\027 / CR: ', 'x'}
+ local expected_lf = { 'line 1', 'ESC:\027 / CR: \rx' }
+ local expected_crlf = { 'line 1', 'ESC:\027 / CR: ', 'x' }
local expected_grid1 = [[
line 1 |
- ESC:{11:^[} / CR: |
+ ESC:{6:^[} / CR: |
{1:x} |
{4:~ }|
{5:[No Name] [+] 3,1 All}|
|
{3:-- TERMINAL --} |
]]
- local expected_attr = {
- [1] = {reverse = true},
- [3] = {bold = true},
- [4] = {foreground = tonumber('0x00000c')},
- [5] = {bold = true, reverse = true},
- [11] = {foreground = tonumber('0x000051')},
- [12] = {reverse = true, foreground = tonumber('0x000051')},
- }
-- "bracketed paste"
- feed_data('\027[200~'..table.concat(expected_lf,'\n')..'\027[201~')
- screen:expect{grid=expected_grid1, attr_ids=expected_attr}
+ feed_data('\027[200~' .. table.concat(expected_lf, '\n') .. '\027[201~')
+ screen:expect(expected_grid1)
-- Dot-repeat/redo.
feed_data('.')
- screen:expect{grid=[[
- ESC:{11:^[} / CR: |
+ screen:expect([[
+ ESC:{6:^[} / CR: |
xline 1 |
- ESC:{11:^[} / CR: |
+ ESC:{6:^[} / CR: |
{1:x} |
{5:[No Name] [+] 5,1 Bot}|
|
{3:-- TERMINAL --} |
- ]], attr_ids=expected_attr}
+ ]])
-- Undo.
feed_data('u')
expect_child_buf_lines(expected_crlf)
feed_data('u')
- expect_child_buf_lines({''})
+ expect_child_buf_lines({ '' })
feed_data(':echo')
wait_for_mode('c')
feed_data('\n')
wait_for_mode('n')
-- CRLF input
- feed_data('\027[200~'..table.concat(expected_lf,'\r\n')..'\027[201~')
- screen:expect{grid=expected_grid1, attr_ids=expected_attr}
+ feed_data('\027[200~' .. table.concat(expected_lf, '\r\n') .. '\027[201~')
+ screen:expect(expected_grid1)
expect_child_buf_lines(expected_crlf)
end)
it('paste: cmdline-mode inserts 1 line', function()
- feed_data('ifoo\n') -- Insert some text (for dot-repeat later).
- feed_data('\027:""') -- Enter Cmdline-mode.
- feed_data('\027[D') -- <Left> to place cursor between quotes.
+ feed_data('ifoo\n') -- Insert some text (for dot-repeat later).
+ feed_data('\027:""') -- Enter Cmdline-mode.
+ feed_data('\027[D') -- <Left> to place cursor between quotes.
wait_for_mode('c')
+ screen:expect([[
+ foo |
+ |
+ {4:~ }|*2
+ {5:[No Name] [+] }|
+ :"{1:"} |
+ {3:-- TERMINAL --} |
+ ]])
-- "bracketed paste"
feed_data('\027[200~line 1\nline 2\n')
wait_for_mode('c')
feed_data('line 3\nline 4\n\027[201~')
wait_for_mode('c')
- screen:expect{grid=[[
+ screen:expect([[
foo |
|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
:"line 1{1:"} |
{3:-- TERMINAL --} |
- ]]}
+ ]])
-- Dot-repeat/redo.
feed_data('\027[27u')
wait_for_mode('n')
feed_data('.')
- screen:expect{grid=[[
- foo |
- foo |
+ screen:expect([[
+ foo |*2
{1: } |
{4:~ }|
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
end)
it('paste: cmdline-mode collects chunks of unfinished line', function()
local function expect_cmdline(expected)
retry(nil, nil, function()
- local _, cmdline = child_session:request(
- 'nvim_call_function', 'getcmdline', {})
+ local _, cmdline = child_session:request('nvim_call_function', 'getcmdline', {})
eq(expected, cmdline)
+ local _, pos = child_session:request('nvim_call_function', 'getcmdpos', {})
+ eq(#expected, pos) -- Cursor is just before the last char.
end)
end
- feed_data('\027:""') -- Enter Cmdline-mode.
- feed_data('\027[D') -- <Left> to place cursor between quotes.
- wait_for_mode('c')
+ feed_data('\027:""') -- Enter Cmdline-mode.
+ feed_data('\027[D') -- <Left> to place cursor between quotes.
+ expect_cmdline('""')
feed_data('\027[200~stuff 1 ')
expect_cmdline('"stuff 1 "')
-- Discards everything after the first line.
@@ -1153,27 +1185,30 @@ describe('TUI', function()
end)
it('paste: recovers from vim.paste() failure', function()
- child_session:request('nvim_exec_lua', [[
+ child_session:request(
+ 'nvim_exec_lua',
+ [[
_G.save_paste_fn = vim.paste
-- Stack traces for this test are non-deterministic, so disable them
_G.debug.traceback = function(msg) return msg end
vim.paste = function(lines, phase) error("fake fail") end
- ]], {})
+ ]],
+ {}
+ )
-- Prepare something for dot-repeat/redo.
feed_data('ifoo\n\027[27u')
wait_for_mode('n')
- screen:expect{grid=[[
+ screen:expect([[
foo |
{1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
-- Start pasting...
feed_data('\027[200~line 1\nline 2\n')
- screen:expect{grid=[[
+ screen:expect([[
foo |
|
{5: }|
@@ -1181,44 +1216,39 @@ describe('TUI', function()
{8:ake fail} |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]])
-- Remaining chunks are discarded after vim.paste() failure.
feed_data('line 3\nline 4\n')
feed_data('line 5\nline 6\n')
feed_data('line 7\nline 8\n')
-- Stop paste.
feed_data('\027[201~')
- feed_data('\n') -- <CR>
- expect_child_buf_lines({'foo',''})
- --Dot-repeat/redo is not modified by failed paste.
+ feed_data('\n') -- <CR> to dismiss hit-enter prompt
+ expect_child_buf_lines({ 'foo', '' })
+ -- Dot-repeat/redo is not modified by failed paste.
feed_data('.')
- screen:expect{grid=[[
- foo |
- foo |
+ screen:expect([[
+ foo |*2
{1: } |
{4:~ }|
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
-- Editor should still work after failed/drained paste.
feed_data('ityped input...\027[27u')
- screen:expect{grid=[[
- foo |
- foo |
+ screen:expect([[
+ foo |*2
typed input..{1:.} |
{4:~ }|
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
-- Paste works if vim.paste() succeeds.
- child_session:request('nvim_exec_lua', [[
- vim.paste = _G.save_paste_fn
- ]], {})
+ child_session:request('nvim_exec_lua', [[vim.paste = _G.save_paste_fn]], {})
feed_data('\027[200~line A\nline B\n\027[201~')
- feed_data('\n') -- <CR>
- screen:expect{grid=[[
+ screen:expect([[
foo |
typed input...line A |
line B |
@@ -1226,28 +1256,36 @@ describe('TUI', function()
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
end)
it('paste: vim.paste() cancel (retval=false) #10865', function()
-- This test only exercises the "cancel" case. Use-case would be "dangling
-- paste", but that is not implemented yet. #10865
- child_session:request('nvim_exec_lua', [[
+ child_session:request(
+ 'nvim_exec_lua',
+ [[
vim.paste = function(lines, phase) return false end
- ]], {})
+ ]],
+ {}
+ )
feed_data('\027[200~line A\nline B\n\027[201~')
feed_data('ifoo\n\027[27u')
- expect_child_buf_lines({'foo',''})
+ expect_child_buf_lines({ 'foo', '' })
end)
it("paste: 'nomodifiable' buffer", function()
child_session:request('nvim_command', 'set nomodifiable')
- child_session:request('nvim_exec_lua', [[
+ child_session:request(
+ 'nvim_exec_lua',
+ [[
-- Truncate the error message to hide the line number
_G.debug.traceback = function(msg) return msg:sub(-49) end
- ]], {})
+ ]],
+ {}
+ )
feed_data('\027[200~fail 1\nfail 2\n\027[201~')
- screen:expect{grid=[[
+ screen:expect([[
|
{4:~ }|
{5: }|
@@ -1255,11 +1293,11 @@ describe('TUI', function()
{8:hanges, 'modifiable' is off} |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
- ]]}
- feed_data('\n') -- <Enter>
+ ]])
+ feed_data('\n') -- <Enter> to dismiss hit-enter prompt
child_session:request('nvim_command', 'set modifiable')
feed_data('\027[200~success 1\nsuccess 2\n\027[201~')
- screen:expect{grid=[[
+ screen:expect([[
success 1 |
success 2 |
{1: } |
@@ -1267,7 +1305,7 @@ describe('TUI', function()
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]])
end)
it('paste: exactly 64 bytes #10311', function()
@@ -1275,20 +1313,19 @@ describe('TUI', function()
feed_data('i')
wait_for_mode('i')
-- "bracketed paste"
- feed_data('\027[200~'..expected..'\027[201~')
- expect_child_buf_lines({expected})
+ feed_data('\027[200~' .. expected .. '\027[201~')
+ expect_child_buf_lines({ expected })
feed_data(' end')
- expected = expected..' end'
+ expected = expected .. ' end'
screen:expect([[
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz|
zzzzzzzzzzzzzz end{1: } |
- {4:~ }|
- {4:~ }|
+ {4:~ }|*2
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- expect_child_buf_lines({expected})
+ expect_child_buf_lines({ expected })
end)
it('paste: less-than sign in cmdline #11088', function()
@@ -1296,16 +1333,14 @@ describe('TUI', function()
feed_data(':')
wait_for_mode('c')
-- "bracketed paste"
- feed_data('\027[200~'..expected..'\027[201~')
- screen:expect{grid=[[
+ feed_data('\027[200~' .. expected .. '\027[201~')
+ screen:expect([[
|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
:<{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]])
end)
it('paste: big burst of input', function()
@@ -1317,7 +1352,7 @@ describe('TUI', function()
feed_data('i')
wait_for_mode('i')
-- "bracketed paste"
- feed_data('\027[200~'..table.concat(t, '\n')..'\027[201~')
+ feed_data('\027[200~' .. table.concat(t, '\n') .. '\027[201~')
expect_child_buf_lines(t)
feed_data(' end')
screen:expect([[
@@ -1329,7 +1364,7 @@ describe('TUI', function()
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data('\027[27u') -- ESC: go to Normal mode.
+ feed_data('\027[27u') -- ESC: go to Normal mode.
wait_for_mode('n')
-- Dot-repeat/redo.
feed_data('.')
@@ -1347,9 +1382,10 @@ describe('TUI', function()
it('paste: forwards spurious "start paste" code', function()
-- If multiple "start paste" sequences are sent without a corresponding
-- "stop paste" sequence, only the first occurrence should be consumed.
-
+ feed_data('i')
+ wait_for_mode('i')
-- Send the "start paste" sequence.
- feed_data('i\027[200~')
+ feed_data('\027[200~')
feed_data('\npasted from terminal (1)\n')
-- Send spurious "start paste" sequence.
feed_data('\027[200~')
@@ -1357,7 +1393,7 @@ describe('TUI', function()
-- Send the "stop paste" sequence.
feed_data('\027[201~')
- screen:expect{grid=[[
+ screen:expect([[
|
pasted from terminal (1) |
{6:^[}[200~ |
@@ -1365,27 +1401,19 @@ describe('TUI', function()
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
- ]], attr_ids={
- [1] = {reverse = true},
- [2] = {background = tonumber('0x00000b')},
- [3] = {bold = true},
- [4] = {foreground = tonumber('0x00000c')},
- [5] = {bold = true, reverse = true},
- [6] = {foreground = tonumber('0x000051')},
- }}
+ ]])
end)
it('paste: ignores spurious "stop paste" code', function()
-- If "stop paste" sequence is received without a preceding "start paste"
-- sequence, it should be ignored.
feed_data('i')
+ wait_for_mode('i')
-- Send "stop paste" sequence.
feed_data('\027[201~')
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
@@ -1394,23 +1422,13 @@ describe('TUI', function()
it('paste: split "start paste" code', function()
feed_data('i')
- screen:expect{grid=[[
- {1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] }|
- {3:-- INSERT --} |
- {3:-- TERMINAL --} |
- ]]}
+ wait_for_mode('i')
-- Send split "start paste" sequence.
feed_data('\027[2')
feed_data('00~pasted from terminal\027[201~')
screen:expect([[
pasted from terminal{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
@@ -1419,23 +1437,13 @@ describe('TUI', function()
it('paste: split "stop paste" code', function()
feed_data('i')
- screen:expect{grid=[[
- {1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] }|
- {3:-- INSERT --} |
- {3:-- TERMINAL --} |
- ]]}
+ wait_for_mode('i')
-- Send split "stop paste" sequence.
feed_data('\027[200~pasted from terminal\027[20')
feed_data('1~')
screen:expect([[
pasted from terminal{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
@@ -1443,7 +1451,9 @@ describe('TUI', function()
end)
it('paste: streamed paste with isolated "stop paste" code', function()
- child_session:request('nvim_exec_lua', [[
+ child_session:request(
+ 'nvim_exec_lua',
+ [[
_G.paste_phases = {}
vim.paste = (function(overridden)
return function(lines, phase)
@@ -1451,57 +1461,47 @@ describe('TUI', function()
overridden(lines, phase)
end
end)(vim.paste)
- ]], {})
+ ]],
+ {}
+ )
feed_data('i')
- screen:expect{grid=[[
- {1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] }|
- {3:-- INSERT --} |
- {3:-- TERMINAL --} |
- ]]}
- feed_data('\027[200~pasted') -- phase 1
+ wait_for_mode('i')
+ feed_data('\027[200~pasted') -- phase 1
screen:expect([[
pasted{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data(' from terminal') -- phase 2
+ feed_data(' from terminal') -- phase 2
screen:expect([[
pasted from terminal{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
-- Send isolated "stop paste" sequence.
- feed_data('\027[201~') -- phase 3
+ feed_data('\027[201~') -- phase 3
screen:expect_unchanged()
local _, rv = child_session:request('nvim_exec_lua', [[return _G.paste_phases]], {})
- eq({1, 2, 3}, rv)
+ eq({ 1, 2, 3 }, rv)
end)
it('allows termguicolors to be set at runtime', function()
screen:set_option('rgb', true)
screen:set_default_attr_ids({
- [1] = {reverse = true},
- [2] = {foreground = tonumber('0x4040ff'), fg_indexed=true},
- [3] = {bold = true, reverse = true},
- [4] = {bold = true},
- [5] = {reverse = true, foreground = tonumber('0xe0e000'), fg_indexed=true},
- [6] = {foreground = tonumber('0xe0e000'), fg_indexed=true},
- [7] = {reverse = true, foreground = Screen.colors.SeaGreen4},
- [8] = {foreground = Screen.colors.SeaGreen4},
- [9] = {bold = true, foreground = Screen.colors.Blue1},
- [10] = {foreground = Screen.colors.Blue},
+ [1] = { reverse = true },
+ [2] = { foreground = tonumber('0x4040ff'), fg_indexed = true },
+ [3] = { bold = true, reverse = true },
+ [4] = { bold = true },
+ [5] = { reverse = true, foreground = tonumber('0xe0e000'), fg_indexed = true },
+ [6] = { foreground = tonumber('0xe0e000'), fg_indexed = true },
+ [7] = { reverse = true, foreground = Screen.colors.SeaGreen4 },
+ [8] = { foreground = Screen.colors.SeaGreen4 },
+ [9] = { bold = true, foreground = Screen.colors.Blue1 },
+ [10] = { foreground = Screen.colors.Blue },
})
feed_data(':hi SpecialKey ctermfg=3 guifg=SeaGreen\n')
@@ -1511,9 +1511,7 @@ describe('TUI', function()
feed_data(':set termguicolors?\n')
screen:expect([[
{5:^}{6:G} |
- {2:~ }|
- {2:~ }|
- {2:~ }|
+ {2:~ }|*3
{3:[No Name] [+] }|
notermguicolors |
{4:-- TERMINAL --} |
@@ -1522,9 +1520,7 @@ describe('TUI', function()
feed_data(':set termguicolors\n')
screen:expect([[
{7:^}{8:G} |
- {9:~}{10: }|
- {9:~}{10: }|
- {9:~}{10: }|
+ {9:~}{10: }|*3
{3:[No Name] [+] }|
:set termguicolors |
{4:-- TERMINAL --} |
@@ -1533,9 +1529,7 @@ describe('TUI', function()
feed_data(':set notermguicolors\n')
screen:expect([[
{5:^}{6:G} |
- {2:~ }|
- {2:~ }|
- {2:~ }|
+ {2:~ }|*3
{3:[No Name] [+] }|
:set notermguicolors |
{4:-- TERMINAL --} |
@@ -1544,50 +1538,54 @@ describe('TUI', function()
it('forwards :term palette colors with termguicolors', function()
if is_ci('github') then
- pending("tty-test complains about not owning the terminal -- actions/runner#241")
+ pending('tty-test complains about not owning the terminal -- actions/runner#241')
end
screen:set_rgb_cterm(true)
screen:set_default_attr_ids({
- [1] = {{reverse = true}, {reverse = true}},
- [2] = {{bold = true, reverse = true}, {bold = true, reverse = true}},
- [3] = {{bold = true}, {bold = true}},
- [4] = {{fg_indexed = true, foreground = tonumber('0xe0e000')}, {foreground = 3}},
- [5] = {{foreground = tonumber('0xff8000')}, {}},
+ [1] = { { reverse = true }, { reverse = true } },
+ [2] = { { bold = true, reverse = true }, { bold = true, reverse = true } },
+ [3] = { { bold = true }, { bold = true } },
+ [4] = { { fg_indexed = true, foreground = tonumber('0xe0e000') }, { foreground = 3 } },
+ [5] = { { foreground = tonumber('0xff8000') }, {} },
})
child_exec_lua('vim.o.statusline="^^^^^^^"')
child_exec_lua('vim.o.termguicolors=true')
child_exec_lua('vim.cmd.terminal(...)', testprg('tty-test'))
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:t}ty ready |
- |
- |
- |
+ |*3
{2:^^^^^^^ }|
|
{3:-- TERMINAL --} |
- ]]}
- feed_data(':call chansend(&channel, "\\033[38;5;3mtext\\033[38:2:255:128:0mcolor\\033[0;10mtext")\n')
- screen:expect{grid=[[
+ ]],
+ }
+ feed_data(
+ ':call chansend(&channel, "\\033[38;5;3mtext\\033[38:2:255:128:0mcolor\\033[0;10mtext")\n'
+ )
+ screen:expect {
+ grid = [[
{1:t}ty ready |
{4:text}{5:color}text |
- |
- |
+ |*2
{2:^^^^^^^ }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data(':set notermguicolors\n')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:t}ty ready |
{4:text}colortext |
- |
- |
+ |*2
{2:^^^^^^^ }|
:set notermguicolors |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end)
it('in nvim_list_uis()', function()
@@ -1613,7 +1611,7 @@ describe('TUI', function()
term_background = '',
term_colors = 256,
term_name = exp_term,
- width = 50
+ width = 50,
},
}
local _, rv = child_session:request('nvim_list_uis')
@@ -1621,10 +1619,17 @@ describe('TUI', function()
end)
it('allows grid to assume wider ambiguous-width characters than host terminal #19686', function()
- child_session:request('nvim_buf_set_lines', 0, 0, -1, true, { ('℃'):rep(60), ('℃'):rep(60) })
+ child_session:request(
+ 'nvim_buf_set_lines',
+ 0,
+ 0,
+ -1,
+ true,
+ { ('℃'):rep(60), ('℃'):rep(60) }
+ )
child_session:request('nvim_set_option_value', 'cursorline', true, {})
child_session:request('nvim_set_option_value', 'list', true, {})
- child_session:request('nvim_set_option_value', 'listchars', 'eol:$', {win=0})
+ child_session:request('nvim_set_option_value', 'listchars', 'eol:$', { win = 0 })
feed_data('gg')
local singlewidth_screen = [[
{13:℃}{12:℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃℃}|
@@ -1651,9 +1656,9 @@ describe('TUI', function()
screen:expect(doublewidth_screen)
child_session:request('nvim_set_option_value', 'ambiwidth', 'single', {})
screen:expect(singlewidth_screen)
- child_session:request('nvim_call_function', 'setcellwidths', {{{0x2103, 0x2103, 2}}})
+ child_session:request('nvim_call_function', 'setcellwidths', { { { 0x2103, 0x2103, 2 } } })
screen:expect(doublewidth_screen)
- child_session:request('nvim_call_function', 'setcellwidths', {{{0x2103, 0x2103, 1}}})
+ child_session:request('nvim_call_function', 'setcellwidths', { { { 0x2103, 0x2103, 1 } } })
screen:expect(singlewidth_screen)
end)
@@ -1661,92 +1666,106 @@ describe('TUI', function()
helpers.skip(is_os('mac'), 'FIXME: crashes/errors on macOS')
screen:try_resize(77, 855)
retry(nil, nil, function()
- eq({true, 852}, {child_session:request('nvim_win_get_height', 0)})
+ eq({ true, 852 }, { child_session:request('nvim_win_get_height', 0) })
end)
-- Use full screen message so that redrawing afterwards is more deterministic.
child_session:notify('nvim_command', 'intro')
- screen:expect({any = 'Nvim'})
+ screen:expect({ any = 'Nvim' })
-- Going to top-left corner needs 3 bytes.
-- Setting underline attribute needs 9 bytes.
- -- The whole line needs 3 + 9 + 65515 + 3 = 65530 bytes.
+ -- The whole line needs 3 + 9 + 65513 + 3 = 65528 bytes.
-- The cursor_address that comes after will overflow the 65535-byte buffer.
- local line = ('a'):rep(65515) .. '℃'
- child_session:notify('nvim_exec_lua', [[
+ local line = ('a'):rep(65513) .. '℃'
+ child_session:notify(
+ 'nvim_exec_lua',
+ [[
vim.api.nvim_buf_set_lines(0, 0, -1, true, {...})
vim.o.cursorline = true
- ]], {line, 'b'})
+ ]],
+ { line, 'b' }
+ )
-- Close the :intro message and redraw the lines.
feed_data('\n')
screen:expect(
- '{13:a}{12:' .. ('a'):rep(76) .. '}|\n'
- .. ('{12:' .. ('a'):rep(77) .. '}|\n'):rep(849)
- .. '{12:' .. ('a'):rep(65) .. '℃' .. (' '):rep(11) .. '}|\n' .. dedent([[
+ '{13:a}{12:'
+ .. ('a'):rep(76)
+ .. '}|\n'
+ .. ('{12:' .. ('a'):rep(77) .. '}|\n'):rep(849)
+ .. '{12:'
+ .. ('a'):rep(63)
+ .. '℃'
+ .. (' '):rep(13)
+ .. '}|\n'
+ .. dedent([[
b |
{5:[No Name] [+] }|
|
- {3:-- TERMINAL --} |]]))
+ {3:-- TERMINAL --} |]])
+ )
end)
it('visual bell (padding) does not crash #21610', function()
feed_data ':set visualbell\n'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
:set visualbell |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
-- move left is enough to invoke the bell
feed_data 'h'
-- visual change to show we process events after this
feed_data 'i'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end)
it('no assert failure on deadly signal #21896', function()
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
Vim: Caught deadly signal 'SIGTERM' |
- |
- |
+ |*2
[Process exited 1]{1: } |
- |
- |
+ |*2
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end)
it('no stack-use-after-scope with cursor color #22432', function()
screen:set_option('rgb', true)
command('set termguicolors')
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
set tgc
hi Cursor guifg=Red guibg=Green
set guicursor=n:block-Cursor/lCursor
- ]], {})
+ ]],
+ {}
+ )
screen:set_default_attr_ids({
- [1] = {reverse = true},
- [2] = {bold = true, foreground = Screen.colors.Blue},
- [3] = {foreground = Screen.colors.Blue},
- [4] = {reverse = true, bold = true},
- [5] = {bold = true},
+ [1] = { reverse = true },
+ [2] = { bold = true, foreground = Screen.colors.Blue },
+ [3] = { foreground = Screen.colors.Blue },
+ [4] = { reverse = true, bold = true },
+ [5] = { bold = true },
})
screen:expect([[
{1: } |
- {2:~}{3: }|
- {2:~}{3: }|
- {2:~}{3: }|
+ {2:~}{3: }|*3
{4:[No Name] }|
|
{5:-- TERMINAL --} |
@@ -1754,9 +1773,7 @@ describe('TUI', function()
feed_data('i')
screen:expect([[
{1: } |
- {2:~}{3: }|
- {2:~}{3: }|
- {2:~}{3: }|
+ {2:~}{3: }|*3
{4:[No Name] }|
{5:-- INSERT --} |
{5:-- TERMINAL --} |
@@ -1764,12 +1781,10 @@ describe('TUI', function()
end)
it('redraws on SIGWINCH even if terminal size is unchanged #23411', function()
- child_session:request('nvim_echo', {{'foo'}}, false, {})
+ child_session:request('nvim_echo', { { 'foo' } }, false, {})
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
foo |
{3:-- TERMINAL --} |
@@ -1777,9 +1792,7 @@ describe('TUI', function()
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigwinch')]])
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
|
{3:-- TERMINAL --} |
@@ -1787,14 +1800,14 @@ describe('TUI', function()
end)
it('supports hiding cursor', function()
- child_session:request('nvim_command',
- "let g:id = jobstart([v:progpath, '--clean', '--headless'])")
+ child_session:request(
+ 'nvim_command',
+ "let g:id = jobstart([v:progpath, '--clean', '--headless'])"
+ )
feed_data(':call jobwait([g:id])\n')
screen:expect([[
|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
:call jobwait([g:id]) |
{3:-- TERMINAL --} |
@@ -1802,14 +1815,73 @@ describe('TUI', function()
feed_data('\003')
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
Type :qa and press <Enter> to exit Nvim |
{3:-- TERMINAL --} |
]])
end)
+
+ it('cursor is not hidden on incsearch with no match', function()
+ feed_data('ifoo\027')
+ feed_data('/foo')
+ screen:expect([[
+ {1:foo} |
+ {4:~ }|*3
+ {5:[No Name] [+] }|
+ /foo{1: } |
+ {3:-- TERMINAL --} |
+ ]])
+ screen:sleep(10)
+ feed_data('b')
+ screen:expect([[
+ foo |
+ {4:~ }|*3
+ {5:[No Name] [+] }|
+ /foob{1: } |
+ {3:-- TERMINAL --} |
+ ]])
+ screen:sleep(10)
+ feed_data('a')
+ screen:expect([[
+ foo |
+ {4:~ }|*3
+ {5:[No Name] [+] }|
+ /fooba{1: } |
+ {3:-- TERMINAL --} |
+ ]])
+ end)
+
+ it('emits hyperlinks with OSC 8', function()
+ exec_lua([[
+ local buf = vim.api.nvim_get_current_buf()
+ _G.urls = {}
+ vim.api.nvim_create_autocmd('TermRequest', {
+ buffer = buf,
+ callback = function(args)
+ local req = args.data
+ if not req then
+ return
+ end
+ local url = req:match('\027]8;;(.*)$')
+ if url ~= nil then
+ table.insert(_G.urls, url)
+ end
+ end,
+ })
+ ]])
+ child_exec_lua([[
+ vim.api.nvim_buf_set_lines(0, 0, 0, true, {'Hello'})
+ local ns = vim.api.nvim_create_namespace('test')
+ vim.api.nvim_buf_set_extmark(0, ns, 0, 1, {
+ end_col = 3,
+ url = 'https://example.com',
+ })
+ ]])
+ retry(nil, 1000, function()
+ eq({ 'https://example.com', '' }, exec_lua([[return _G.urls]]))
+ end)
+ end)
end)
describe('TUI', function()
@@ -1818,25 +1890,34 @@ describe('TUI', function()
it('resize at startup #17285 #15044 #11330', function()
local screen = Screen.new(50, 10)
screen:set_default_attr_ids({
- [1] = {reverse = true},
- [2] = {bold = true, foreground = Screen.colors.Blue},
- [3] = {bold = true},
- [4] = {foreground = tonumber('0x4040ff'), fg_indexed = true},
- [5] = {bold = true, reverse = true},
+ [1] = { reverse = true },
+ [2] = { bold = true, foreground = Screen.colors.Blue },
+ [3] = { bold = true },
+ [4] = { foreground = tonumber('0x4040ff'), fg_indexed = true },
+ [5] = { bold = true, reverse = true },
})
screen:attach()
+ fn.termopen({
+ nvim_prog,
+ '--clean',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set notermguicolors',
+ '--cmd',
+ 'let start = reltime() | while v:true | if reltimefloat(reltime(start)) > 2 | break | endif | endwhile',
+ }, {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+ },
+ })
exec([[
- call termopen([v:progpath, '--clean', '--cmd', 'let start = reltime() | while v:true | if reltimefloat(reltime(start)) > 2 | break | endif | endwhile'])
sleep 500m
vs new
]])
screen:expect([[
^ │ |
- {2:~ }│{4:~ }|
- {2:~ }│{4:~ }|
- {2:~ }│{4:~ }|
- {2:~ }│{4:~ }|
- {2:~ }│{4:~ }|
+ {2:~ }│{4:~ }|*5
{2:~ }│{5:[No Name] 0,0-1 All}|
{2:~ }│ |
{5:new }{1:{MATCH:<.*[/\]nvim }}|
@@ -1849,43 +1930,53 @@ describe('TUI', function()
pending('missing LuaJIT FFI')
end
local script_file = 'Xargv0.lua'
- write_file(script_file, [=[
+ write_file(
+ script_file,
+ [=[
local ffi = require('ffi')
ffi.cdef([[int execl(const char *, const char *, ...);]])
- ffi.C.execl(vim.v.progpath, 'Xargv0nvim', '--clean')
- ]=])
+ ffi.C.execl(vim.v.progpath, 'Xargv0nvim', '--clean', nil)
+ ]=]
+ )
finally(function()
os.remove(script_file)
end)
- local screen = thelpers.screen_setup(0, string.format([=[["%s", "--clean", "-l", "%s"]]=],
- nvim_prog, script_file))
- screen:expect{grid=[[
+ local screen = thelpers.setup_child_nvim({ '--clean', '-l', script_file })
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] 0,0-1 All}|
+ ~ |*3
+ [No Name] 0,0-1 All|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data(':put =v:argv + [v:progname]\n')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
Xargv0nvim |
--embed |
--clean |
{1:X}argv0nvim |
- {5:[No Name] [+] 5,1 Bot}|
+ [No Name] [+] 5,1 Bot|
4 more lines |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end)
it('with non-tty (pipe) stdout/stderr', function()
finally(function()
os.remove('testF')
end)
- local screen = thelpers.screen_setup(0, '"'..nvim_prog
- ..' -u NONE -i NONE --cmd \'set noswapfile noshowcmd noruler\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
+ local screen = thelpers.screen_setup(
+ 0,
+ ('"%s" -u NONE -i NONE --cmd "set noswapfile noshowcmd noruler" --cmd "normal iabc" > /dev/null 2>&1 && cat testF && rm testF'):format(
+ nvim_prog
+ ),
+ nil,
+ { VIMRUNTIME = os.getenv('VIMRUNTIME') }
+ )
feed_data(':w testF\n:q\n')
screen:expect([[
:w testF |
@@ -1899,24 +1990,32 @@ describe('TUI', function()
end)
it('<C-h> #10134', function()
- local screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..[[", "-u", "NONE", "-i", "NONE", "--cmd", "set noruler", "--cmd", ':nnoremap <C-h> :echomsg "\<C-h\>"<CR>']]..']')
- screen:expect{grid=[[
+ local screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set noruler notermguicolors',
+ '--cmd',
+ ':nnoremap <C-h> :echomsg "\\<C-h\\>"<CR>',
+ })
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
command([[call chansend(b:terminal_job_id, "\<C-h>")]])
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
<C-h> |
{3:-- TERMINAL --} |
@@ -1924,19 +2023,31 @@ describe('TUI', function()
end)
it('draws line with many trailing spaces correctly #24955', function()
- local screen = thelpers.screen_setup(0, '["'..nvim_prog..[[", "-u", "NONE", "-i", "NONE"]]
- ..[[, "--cmd", "call setline(1, ['1st line' .. repeat(' ', 153), '2nd line'])"]]..']', 80)
- screen:expect{grid=[[
+ local screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'set notermguicolors',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'call setline(1, ["1st line" .. repeat(" ", 153), "2nd line"])',
+ }, { cols = 80 })
+ screen:expect {
+ grid = [[
{1:1}st line |
- |
- |
+ |*2
2nd line |
{5:[No Name] [+] 1,1 All}|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data('$')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
1st line |
|
{1: } |
@@ -1944,41 +2055,93 @@ describe('TUI', function()
{5:[No Name] [+] 1,161 All}|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
+ end)
+
+ it('no heap-buffer-overflow when changing &columns', function()
+ -- Set a different bg colour and change $TERM to something dumber so the `print_spaces()`
+ -- codepath in `clear_region()` is hit.
+ local screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'set notermguicolors | highlight Normal ctermbg=red',
+ '--cmd',
+ 'call setline(1, ["a"->repeat(&columns)])',
+ }, { env = { TERM = 'ansi' } })
+
+ screen:expect {
+ grid = [[
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
+ ~ |*3
+ [No Name] [+] 1,1 All|
+ |
+ -- TERMINAL -- |
+ ]],
+ attr_ids = {},
+ }
+
+ feed_data(':set columns=12\n')
+ screen:expect {
+ grid = [[
+ aaaaaaaaaaaa |*4
+ < [+] 1,1 |
+ |
+ -- TERMINAL -- |
+ ]],
+ attr_ids = {},
+ }
+
+ -- Wider than TUI, so screen state will look weird.
+ -- Wait for the statusline to redraw to confirm that the TUI lives and ASAN is happy.
+ feed_data(':set columns=99|set stl=redrawn%m\n')
+ screen:expect({ any = 'redrawn%[%+%]' })
end)
end)
describe('TUI UIEnter/UILeave', function()
it('fires exactly once, after VimEnter', function()
clear()
- local screen = thelpers.screen_setup(0,
- '["'..nvim_prog..'", "-u", "NONE", "-i", "NONE"'
- ..[[, "--cmd", "set noswapfile noshowcmd noruler"]]
- ..[[, "--cmd", "let g:evs = []"]]
- ..[[, "--cmd", "autocmd UIEnter * :call add(g:evs, 'UIEnter')"]]
- ..[[, "--cmd", "autocmd UILeave * :call add(g:evs, 'UILeave')"]]
- ..[[, "--cmd", "autocmd VimEnter * :call add(g:evs, 'VimEnter')"]]
- ..']'
- )
- screen:expect{grid=[[
+ local screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set noswapfile noshowcmd noruler notermguicolors',
+ '--cmd',
+ 'let g:evs = []',
+ '--cmd',
+ 'autocmd UIEnter * :call add(g:evs, "UIEnter")',
+ '--cmd',
+ 'autocmd UILeave * :call add(g:evs, "UILeave")',
+ '--cmd',
+ 'autocmd VimEnter * :call add(g:evs, "VimEnter")',
+ })
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
|
{3:-- TERMINAL --} |
- ]]}
- feed_data(":echo g:evs\n")
- screen:expect{grid=[[
+ ]],
+ }
+ feed_data(':echo g:evs\n')
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
['VimEnter', 'UIEnter'] |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
end)
end)
@@ -1989,25 +2152,36 @@ describe('TUI FocusGained/FocusLost', function()
before_each(function()
clear()
local child_server = new_pipename()
- screen = thelpers.screen_setup(0,
- string.format(
- [=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]]=],
- nvim_prog, child_server))
+ screen = thelpers.setup_child_nvim({
+ '--listen',
+ child_server,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set noswapfile noshowcmd noruler notermguicolors background=dark',
+ })
+
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
|
{3:-- TERMINAL --} |
]])
child_session = helpers.connect(child_server)
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
autocmd FocusGained * echo 'gained'
autocmd FocusLost * echo 'lost'
- ]], {})
- feed_data("\034\016") -- CTRL-\ CTRL-N
+ ]],
+ {}
+ )
+ feed_data('\034\016') -- CTRL-\ CTRL-N
end)
it('in normal-mode', function()
@@ -2015,9 +2189,7 @@ describe('TUI FocusGained/FocusLost', function()
feed_data('\027[I')
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
gained |
{3:-- TERMINAL --} |
@@ -2026,9 +2198,7 @@ describe('TUI FocusGained/FocusLost', function()
feed_data('\027[O')
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
lost |
{3:-- TERMINAL --} |
@@ -2039,22 +2209,20 @@ describe('TUI FocusGained/FocusLost', function()
it('in insert-mode', function()
feed_data(':set noshowmode\r')
feed_data('i')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
:set noshowmode |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
retry(2, 3 * screen.timeout, function()
feed_data('\027[I')
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
gained |
{3:-- TERMINAL --} |
@@ -2062,9 +2230,7 @@ describe('TUI FocusGained/FocusLost', function()
feed_data('\027[O')
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
lost |
{3:-- TERMINAL --} |
@@ -2079,34 +2245,37 @@ describe('TUI FocusGained/FocusLost', function()
feed_data('\027[I')
screen:expect([[
|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
:{1: } |
{3:-- TERMINAL --} |
]])
feed_data('\027[O')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
:{1: } |
{3:-- TERMINAL --} |
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
end)
it('in cmdline-mode', function()
-- Set up autocmds that modify the buffer, instead of just calling :echo.
-- This is how we can test handling of focus gained/lost during cmdline-mode.
-- See commit: 5cc87d4dabd02167117be7a978b5c8faaa975419.
- child_session:request('nvim_exec2', [[
+ child_session:request(
+ 'nvim_exec2',
+ [[
autocmd!
autocmd FocusLost * call append(line('$'), 'lost')
autocmd FocusGained * call append(line('$'), 'gained')
- ]], {})
+ ]],
+ {}
+ )
retry(2, 3 * screen.timeout, function()
-- Enter cmdline-mode.
feed_data(':')
@@ -2118,44 +2287,46 @@ describe('TUI FocusGained/FocusLost', function()
-- Exit cmdline-mode. Redraws from timers/events are blocked during
-- cmdline-mode, so the buffer won't be updated until we exit cmdline-mode.
feed_data('\n')
- screen:expect{any='lost'..(' '):rep(46)..'|\ngained'}
+ screen:expect { any = 'lost' .. (' '):rep(46) .. '|\ngained' }
end)
end)
it('in terminal-mode', function()
- feed_data(':set shell='..testprg('shell-test')..' shellcmdflag=EXE\n')
+ feed_data(':set shell=' .. testprg('shell-test') .. ' shellcmdflag=EXE\n')
feed_data(':set noshowmode laststatus=0\n')
feed_data(':terminal zia\n')
-- Wait for terminal to be ready.
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:r}eady $ zia |
|
[Process exited 0] |
- |
- |
+ |*2
:terminal zia |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data('\027[I')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:r}eady $ zia |
|
[Process exited 0] |
- |
- |
+ |*2
gained |
{3:-- TERMINAL --} |
- ]], timeout=(4 * screen.timeout)}
+ ]],
+ timeout = (4 * screen.timeout),
+ }
feed_data('\027[O')
screen:expect([[
{1:r}eady $ zia |
|
[Process exited 0] |
- |
- |
+ |*2
lost |
{3:-- TERMINAL --} |
]])
@@ -2164,8 +2335,9 @@ describe('TUI FocusGained/FocusLost', function()
it('in press-enter prompt', function()
feed_data(":echom 'msg1'|echom 'msg2'|echom 'msg3'|echom 'msg4'|echom 'msg5'\n")
-- Execute :messages to provoke the press-enter prompt.
- feed_data(":messages\n")
- screen:expect{grid=[[
+ feed_data(':messages\n')
+ screen:expect {
+ grid = [[
msg1 |
msg2 |
msg3 |
@@ -2173,10 +2345,12 @@ describe('TUI FocusGained/FocusLost', function()
msg5 |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
feed_data('\027[I')
feed_data('\027[I')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
msg1 |
msg2 |
msg3 |
@@ -2184,7 +2358,9 @@ describe('TUI FocusGained/FocusLost', function()
msg5 |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
end)
end)
@@ -2194,97 +2370,108 @@ describe("TUI 't_Co' (terminal colors)", function()
local screen
local function assert_term_colors(term, colorterm, maxcolors)
- clear({env={TERM=term}, args={}})
- -- This is ugly because :term/termopen() forces TERM=xterm-256color.
- -- TODO: Revisit this after jobstart/termopen accept `env` dict.
- screen = thelpers.screen_setup(0, string.format(
- [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "%s"']]=],
- term or "",
- (colorterm ~= nil and "COLORTERM="..colorterm or ""),
- nvim_prog,
- nvim_set))
+ clear({ env = { TERM = term }, args = {} })
+ screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ nvim_set .. ' notermguicolors',
+ }, {
+ env = {
+ LANG = 'C',
+ TERM = term or '',
+ COLORTERM = colorterm or '',
+ },
+ })
local tline
- if maxcolors == 8 or maxcolors == 16 then
- tline = "~ "
+ if maxcolors == 8 then
+ tline = '{9:~ }'
+ elseif maxcolors == 16 then
+ tline = '~ '
else
- tline = "{4:~ }"
+ tline = '{4:~ }'
end
- screen:expect(string.format([[
+ screen:expect(string.format(
+ [[
{1: } |
- %s|
- %s|
- %s|
- %s|
+ %s|*4
|
{3:-- TERMINAL --} |
- ]], tline, tline, tline, tline))
+ ]],
+ tline
+ ))
- feed_data(":echo &t_Co\n")
- screen:expect(string.format([[
+ feed_data(':echo &t_Co\n')
+ screen:expect(string.format(
+ [[
{1: } |
- %s|
- %s|
- %s|
- %s|
+ %s|*4
%-3s |
{3:-- TERMINAL --} |
- ]], tline, tline, tline, tline, tostring(maxcolors and maxcolors or "")))
+ ]],
+ tline,
+ tostring(maxcolors and maxcolors or '')
+ ))
end
-- ansi and no terminal type at all:
- it("no TERM uses 8 colors", function()
+ it('no TERM uses 8 colors', function()
assert_term_colors(nil, nil, 8)
end)
- it("TERM=ansi no COLORTERM uses 8 colors", function()
- assert_term_colors("ansi", nil, 8)
+ it('TERM=ansi no COLORTERM uses 8 colors', function()
+ assert_term_colors('ansi', nil, 8)
end)
- it("TERM=ansi with COLORTERM=anything-no-number uses 16 colors", function()
- assert_term_colors("ansi", "yet-another-term", 16)
+ it('TERM=ansi with COLORTERM=anything-no-number uses 16 colors', function()
+ assert_term_colors('ansi', 'yet-another-term', 16)
end)
- it("unknown TERM COLORTERM with 256 in name uses 256 colors", function()
- assert_term_colors("ansi", "yet-another-term-256color", 256)
+ it('unknown TERM COLORTERM with 256 in name uses 256 colors', function()
+ assert_term_colors('ansi', 'yet-another-term-256color', 256)
end)
- it("TERM=ansi-256color sets 256 colours", function()
- assert_term_colors("ansi-256color", nil, 256)
+ it('TERM=ansi-256color sets 256 colours', function()
+ assert_term_colors('ansi-256color', nil, 256)
end)
-- Unknown terminal types:
- it("unknown TERM no COLORTERM sets 8 colours", function()
- assert_term_colors("yet-another-term", nil, 8)
+ it('unknown TERM no COLORTERM sets 8 colours', function()
+ assert_term_colors('yet-another-term', nil, 8)
end)
- it("unknown TERM with COLORTERM=anything-no-number uses 16 colors", function()
- assert_term_colors("yet-another-term", "yet-another-term", 16)
+ it('unknown TERM with COLORTERM=anything-no-number uses 16 colors', function()
+ assert_term_colors('yet-another-term', 'yet-another-term', 16)
end)
- it("unknown TERM with 256 in name sets 256 colours", function()
- assert_term_colors("yet-another-term-256color", nil, 256)
+ it('unknown TERM with 256 in name sets 256 colours', function()
+ assert_term_colors('yet-another-term-256color', nil, 256)
end)
- it("unknown TERM COLORTERM with 256 in name uses 256 colors", function()
- assert_term_colors("yet-another-term", "yet-another-term-256color", 256)
+ it('unknown TERM COLORTERM with 256 in name uses 256 colors', function()
+ assert_term_colors('yet-another-term', 'yet-another-term-256color', 256)
end)
-- Linux kernel terminal emulator:
- it("TERM=linux uses 256 colors", function()
- assert_term_colors("linux", nil, 256)
+ it('TERM=linux uses 256 colors', function()
+ assert_term_colors('linux', nil, 256)
end)
- it("TERM=linux-16color uses 256 colors", function()
- assert_term_colors("linux-16color", nil, 256)
+ it('TERM=linux-16color uses 256 colors', function()
+ assert_term_colors('linux-16color', nil, 256)
end)
- it("TERM=linux-256color uses 256 colors", function()
- assert_term_colors("linux-256color", nil, 256)
+ it('TERM=linux-256color uses 256 colors', function()
+ assert_term_colors('linux-256color', nil, 256)
end)
-- screen:
@@ -2293,28 +2480,28 @@ describe("TUI 't_Co' (terminal colors)", function()
-- Linux and MacOS have a screen entry in external terminfo with 8 colours,
-- which is raised to 16 by COLORTERM.
- it("TERM=screen no COLORTERM uses 8/256 colors", function()
+ it('TERM=screen no COLORTERM uses 8/256 colors', function()
if is_os('freebsd') then
- assert_term_colors("screen", nil, 256)
+ assert_term_colors('screen', nil, 256)
else
- assert_term_colors("screen", nil, 8)
+ assert_term_colors('screen', nil, 8)
end
end)
- it("TERM=screen COLORTERM=screen uses 16/256 colors", function()
+ it('TERM=screen COLORTERM=screen uses 16/256 colors', function()
if is_os('freebsd') then
- assert_term_colors("screen", "screen", 256)
+ assert_term_colors('screen', 'screen', 256)
else
- assert_term_colors("screen", "screen", 16)
+ assert_term_colors('screen', 'screen', 16)
end
end)
- it("TERM=screen COLORTERM=screen-256color uses 256 colors", function()
- assert_term_colors("screen", "screen-256color", 256)
+ it('TERM=screen COLORTERM=screen-256color uses 256 colors', function()
+ assert_term_colors('screen', 'screen-256color', 256)
end)
- it("TERM=screen-256color no COLORTERM uses 256 colors", function()
- assert_term_colors("screen-256color", nil, 256)
+ it('TERM=screen-256color no COLORTERM uses 256 colors', function()
+ assert_term_colors('screen-256color', nil, 256)
end)
-- tmux:
@@ -2323,38 +2510,38 @@ describe("TUI 't_Co' (terminal colors)", function()
-- Linux has a tmux entry in external terminfo with 8 colours,
-- which is raised to 256.
- it("TERM=tmux no COLORTERM uses 256 colors", function()
- assert_term_colors("tmux", nil, 256)
+ it('TERM=tmux no COLORTERM uses 256 colors', function()
+ assert_term_colors('tmux', nil, 256)
end)
- it("TERM=tmux COLORTERM=tmux uses 256 colors", function()
- assert_term_colors("tmux", "tmux", 256)
+ it('TERM=tmux COLORTERM=tmux uses 256 colors', function()
+ assert_term_colors('tmux', 'tmux', 256)
end)
- it("TERM=tmux COLORTERM=tmux-256color uses 256 colors", function()
- assert_term_colors("tmux", "tmux-256color", 256)
+ it('TERM=tmux COLORTERM=tmux-256color uses 256 colors', function()
+ assert_term_colors('tmux', 'tmux-256color', 256)
end)
- it("TERM=tmux-256color no COLORTERM uses 256 colors", function()
- assert_term_colors("tmux-256color", nil, 256)
+ it('TERM=tmux-256color no COLORTERM uses 256 colors', function()
+ assert_term_colors('tmux-256color', nil, 256)
end)
-- xterm and imitators:
- it("TERM=xterm uses 256 colors", function()
- assert_term_colors("xterm", nil, 256)
+ it('TERM=xterm uses 256 colors', function()
+ assert_term_colors('xterm', nil, 256)
end)
- it("TERM=xterm COLORTERM=gnome-terminal uses 256 colors", function()
- assert_term_colors("xterm", "gnome-terminal", 256)
+ it('TERM=xterm COLORTERM=gnome-terminal uses 256 colors', function()
+ assert_term_colors('xterm', 'gnome-terminal', 256)
end)
- it("TERM=xterm COLORTERM=mate-terminal uses 256 colors", function()
- assert_term_colors("xterm", "mate-terminal", 256)
+ it('TERM=xterm COLORTERM=mate-terminal uses 256 colors', function()
+ assert_term_colors('xterm', 'mate-terminal', 256)
end)
- it("TERM=xterm-256color uses 256 colors", function()
- assert_term_colors("xterm-256color", nil, 256)
+ it('TERM=xterm-256color uses 256 colors', function()
+ assert_term_colors('xterm-256color', nil, 256)
end)
-- rxvt and stterm:
@@ -2364,44 +2551,44 @@ describe("TUI 't_Co' (terminal colors)", function()
-- Linux has an rxvt, an st, and an st-16color entry in external terminfo
-- with 8, 8, and 16 colours respectively, which are raised to 256.
- it("TERM=rxvt no COLORTERM uses 256 colors", function()
- assert_term_colors("rxvt", nil, 256)
+ it('TERM=rxvt no COLORTERM uses 256 colors', function()
+ assert_term_colors('rxvt', nil, 256)
end)
- it("TERM=rxvt COLORTERM=rxvt uses 256 colors", function()
- assert_term_colors("rxvt", "rxvt", 256)
+ it('TERM=rxvt COLORTERM=rxvt uses 256 colors', function()
+ assert_term_colors('rxvt', 'rxvt', 256)
end)
- it("TERM=rxvt-256color uses 256 colors", function()
- assert_term_colors("rxvt-256color", nil, 256)
+ it('TERM=rxvt-256color uses 256 colors', function()
+ assert_term_colors('rxvt-256color', nil, 256)
end)
- it("TERM=st no COLORTERM uses 256 colors", function()
- assert_term_colors("st", nil, 256)
+ it('TERM=st no COLORTERM uses 256 colors', function()
+ assert_term_colors('st', nil, 256)
end)
- it("TERM=st COLORTERM=st uses 256 colors", function()
- assert_term_colors("st", "st", 256)
+ it('TERM=st COLORTERM=st uses 256 colors', function()
+ assert_term_colors('st', 'st', 256)
end)
- it("TERM=st COLORTERM=st-256color uses 256 colors", function()
- assert_term_colors("st", "st-256color", 256)
+ it('TERM=st COLORTERM=st-256color uses 256 colors', function()
+ assert_term_colors('st', 'st-256color', 256)
end)
- it("TERM=st-16color no COLORTERM uses 8/256 colors", function()
- assert_term_colors("st", nil, 256)
+ it('TERM=st-16color no COLORTERM uses 8/256 colors', function()
+ assert_term_colors('st', nil, 256)
end)
- it("TERM=st-16color COLORTERM=st uses 16/256 colors", function()
- assert_term_colors("st", "st", 256)
+ it('TERM=st-16color COLORTERM=st uses 16/256 colors', function()
+ assert_term_colors('st', 'st', 256)
end)
- it("TERM=st-16color COLORTERM=st-256color uses 256 colors", function()
- assert_term_colors("st", "st-256color", 256)
+ it('TERM=st-16color COLORTERM=st-256color uses 256 colors', function()
+ assert_term_colors('st', 'st-256color', 256)
end)
- it("TERM=st-256color uses 256 colors", function()
- assert_term_colors("st-256color", nil, 256)
+ it('TERM=st-256color uses 256 colors', function()
+ assert_term_colors('st-256color', nil, 256)
end)
-- gnome and vte:
@@ -2411,54 +2598,53 @@ describe("TUI 't_Co' (terminal colors)", function()
-- external terminfo with 8, 8, 256, and 256 colours respectively, which are
-- raised to 256.
- it("TERM=gnome no COLORTERM uses 256 colors", function()
- assert_term_colors("gnome", nil, 256)
+ it('TERM=gnome no COLORTERM uses 256 colors', function()
+ assert_term_colors('gnome', nil, 256)
end)
- it("TERM=gnome COLORTERM=gnome uses 256 colors", function()
- assert_term_colors("gnome", "gnome", 256)
+ it('TERM=gnome COLORTERM=gnome uses 256 colors', function()
+ assert_term_colors('gnome', 'gnome', 256)
end)
- it("TERM=gnome COLORTERM=gnome-256color uses 256 colors", function()
- assert_term_colors("gnome", "gnome-256color", 256)
+ it('TERM=gnome COLORTERM=gnome-256color uses 256 colors', function()
+ assert_term_colors('gnome', 'gnome-256color', 256)
end)
- it("TERM=gnome-256color uses 256 colors", function()
- assert_term_colors("gnome-256color", nil, 256)
+ it('TERM=gnome-256color uses 256 colors', function()
+ assert_term_colors('gnome-256color', nil, 256)
end)
- it("TERM=vte no COLORTERM uses 256 colors", function()
- assert_term_colors("vte", nil, 256)
+ it('TERM=vte no COLORTERM uses 256 colors', function()
+ assert_term_colors('vte', nil, 256)
end)
- it("TERM=vte COLORTERM=vte uses 256 colors", function()
- assert_term_colors("vte", "vte", 256)
+ it('TERM=vte COLORTERM=vte uses 256 colors', function()
+ assert_term_colors('vte', 'vte', 256)
end)
- it("TERM=vte COLORTERM=vte-256color uses 256 colors", function()
- assert_term_colors("vte", "vte-256color", 256)
+ it('TERM=vte COLORTERM=vte-256color uses 256 colors', function()
+ assert_term_colors('vte', 'vte-256color', 256)
end)
- it("TERM=vte-256color uses 256 colors", function()
- assert_term_colors("vte-256color", nil, 256)
+ it('TERM=vte-256color uses 256 colors', function()
+ assert_term_colors('vte-256color', nil, 256)
end)
-- others:
-- TODO(blueyed): this is made pending, since it causes failure + later hang
-- when using non-compatible libvterm (#9494/#10179).
- pending("TERM=interix uses 8 colors", function()
- assert_term_colors("interix", nil, 8)
+ pending('TERM=interix uses 8 colors', function()
+ assert_term_colors('interix', nil, 8)
end)
- it("TERM=iTerm.app uses 256 colors", function()
- assert_term_colors("iTerm.app", nil, 256)
+ it('TERM=iTerm.app uses 256 colors', function()
+ assert_term_colors('iTerm.app', nil, 256)
end)
- it("TERM=iterm uses 256 colors", function()
- assert_term_colors("iterm", nil, 256)
+ it('TERM=iterm uses 256 colors', function()
+ assert_term_colors('iterm', nil, 256)
end)
-
end)
-- These tests require `thelpers` because --headless/--embed
@@ -2468,39 +2654,43 @@ describe("TUI 'term' option", function()
local function assert_term(term_envvar, term_expected)
clear()
- -- This is ugly because :term/termopen() forces TERM=xterm-256color.
- -- TODO: Revisit this after jobstart/termopen accept `env` dict.
- local cmd = string.format(
- [=[['sh', '-c', 'LANG=C TERM=%s %s -u NONE -i NONE --cmd "%s"']]=],
- term_envvar or "",
- nvim_prog,
- nvim_set)
- screen = thelpers.screen_setup(0, cmd)
+ screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ nvim_set .. ' notermguicolors',
+ }, {
+ env = {
+ LANG = 'C',
+ TERM = term_envvar or '',
+ },
+ })
local full_timeout = screen.timeout
- screen.timeout = 250 -- We want screen:expect() to fail quickly.
- retry(nil, 2 * full_timeout, function() -- Wait for TUI thread to set 'term'.
+ retry(nil, 2 * full_timeout, function() -- Wait for TUI thread to set 'term'.
feed_data(":echo 'term='.(&term)\n")
- screen:expect{any='term='..term_expected}
+ screen:expect { any = 'term=' .. term_expected, timeout = 250 }
end)
end
it('gets builtin term if $TERM is invalid', function()
- assert_term("foo", "builtin_ansi")
+ assert_term('foo', 'builtin_ansi')
end)
it('gets system-provided term if $TERM is valid', function()
if is_os('openbsd') then
- assert_term("xterm", "xterm")
- elseif is_os('bsd') then -- BSD lacks terminfo, builtin is always used.
- assert_term("xterm", "builtin_xterm")
+ assert_term('xterm', 'xterm')
+ elseif is_os('bsd') then -- BSD lacks terminfo, builtin is always used.
+ assert_term('xterm', 'builtin_xterm')
elseif is_os('mac') then
- local status, _ = pcall(assert_term, "xterm", "xterm")
+ local status, _ = pcall(assert_term, 'xterm', 'xterm')
if not status then
- pending("macOS: unibilium could not find terminfo")
+ pending('macOS: unibilium could not find terminfo')
end
else
- assert_term("xterm", "xterm")
+ assert_term('xterm', 'xterm')
end
end)
@@ -2510,12 +2700,11 @@ describe("TUI 'term' option", function()
assert_term('conemu', 'builtin_conemu')
assert_term('vtpcon', 'builtin_vtpcon')
end)
-
end)
-- These tests require `thelpers` because --headless/--embed
-- does not initialize the TUI.
-describe("TUI", function()
+describe('TUI', function()
local screen
local logfile = 'Xtest_tui_verbose_log'
after_each(function()
@@ -2525,284 +2714,398 @@ describe("TUI", function()
-- Runs (child) `nvim` in a TTY (:terminal), to start the builtin TUI.
local function nvim_tui(extra_args)
clear()
- -- This is ugly because :term/termopen() forces TERM=xterm-256color.
- -- TODO: Revisit this after jobstart/termopen accept `env` dict.
- local cmd = string.format(
- [=[['sh', '-c', 'LANG=C %s -u NONE -i NONE %s --cmd "%s"']]=],
- nvim_prog,
- extra_args or "",
- nvim_set)
- screen = thelpers.screen_setup(0, cmd)
+ screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ nvim_set .. ' notermguicolors',
+ extra_args,
+ }, {
+ env = {
+ LANG = 'C',
+ },
+ })
end
it('-V3log logs terminfo values', function()
- nvim_tui('-V3'..logfile)
+ nvim_tui('-V3' .. logfile)
-- Wait for TUI to start.
feed_data('Gitext')
screen:expect([[
text{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*4
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- retry(nil, 3000, function() -- Wait for log file to be flushed.
+ retry(nil, 3000, function() -- Wait for log file to be flushed.
local log = read_file('Xtest_tui_verbose_log') or ''
eq('--- Terminal info --- {{{\n', string.match(log, '%-%-%- Terminal.-\n')) -- }}}
ok(#log > 50)
end)
end)
-end)
-
--- See test/unit/tui_spec.lua for unit tests.
-describe('TUI bg color', function()
- local screen
-
- local function setup_bg_test()
- clear()
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile", '
- ..'"-c", "autocmd OptionSet background echo \\"did OptionSet, yay!\\""]')
- end
-
- before_each(setup_bg_test)
+ it('does not crash on large inputs #26099', function()
+ nvim_tui()
- it('triggers OptionSet event on unsplit terminal-response', function()
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] 0,0-1 All}|
+ {4:~ }|*4
|
{3:-- TERMINAL --} |
]])
- feed_data('\027]11;rgb:ffff/ffff/ffff\027\\')
- screen:expect{any='did OptionSet, yay!'}
- feed_data(':echo "new_bg=".&background\n')
- screen:expect{any='new_bg=light'}
+ feed_data(string.format('\027]52;c;%s\027\\', string.rep('A', 8192)))
- setup_bg_test()
- screen:expect([[
+ screen:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] 0,0-1 All}|
+ {4:~ }|*4
|
{3:-- TERMINAL --} |
+ ]],
+ unchanged = true,
+ }
+ end)
+
+ it('queries the terminal for truecolor support', function()
+ clear()
+ exec_lua([[
+ vim.api.nvim_create_autocmd('TermRequest', {
+ callback = function(args)
+ local req = args.data
+ local payload = req:match('^\027P%+q([%x;]+)$')
+ if payload then
+ local t = {}
+ for cap in vim.gsplit(payload, ';') do
+ local resp = string.format('\027P1+r%s\027\\', payload)
+ vim.api.nvim_chan_send(vim.bo[args.buf].channel, resp)
+ t[vim.text.hexdecode(cap)] = true
+ end
+ vim.g.xtgettcap = t
+ return true
+ end
+ end,
+ })
]])
- feed_data('\027]11;rgba:ffff/ffff/ffff/8000\027\\')
- screen:expect{any='did OptionSet, yay!'}
- feed_data(':echo "new_bg=".&background\n')
- screen:expect{any='new_bg=light'}
+ local child_server = new_pipename()
+ screen = thelpers.setup_child_nvim({
+ '--listen',
+ child_server,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ }, {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+
+ -- Force COLORTERM to be unset and use a TERM that does not contain Tc or RGB in terminfo.
+ -- This will force the nested nvim instance to query with XTGETTCAP
+ COLORTERM = '',
+ TERM = 'xterm-256colors',
+ },
+ })
+
+ screen:expect({ any = '%[No Name%]' })
+
+ local child_session = helpers.connect(child_server)
+ retry(nil, 1000, function()
+ eq({
+ Tc = true,
+ RGB = true,
+ setrgbf = true,
+ setrgbb = true,
+ }, eval("get(g:, 'xtgettcap', '')"))
+ eq({ true, 1 }, { child_session:request('nvim_eval', '&termguicolors') })
+ end)
end)
- it('triggers OptionSet event with split terminal-response', function()
- screen:expect([[
- {1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] 0,0-1 All}|
- |
- {3:-- TERMINAL --} |
+ it('queries the terminal for OSC 52 support', function()
+ clear()
+ exec_lua([[
+ vim.api.nvim_create_autocmd('TermRequest', {
+ callback = function(args)
+ local req = args.data
+ local payload = req:match('^\027P%+q([%x;]+)$')
+ if payload and vim.text.hexdecode(payload) == 'Ms' then
+ vim.g.xtgettcap = 'Ms'
+ local resp = string.format('\027P1+r%s=%s\027\\', payload, vim.text.hexencode('\027]52;;\027\\'))
+ vim.api.nvim_chan_send(vim.bo[args.buf].channel, resp)
+ return true
+ end
+ end,
+ })
]])
- -- Send a background response with the OSC command part split.
- feed_data('\027]11;rgb')
- feed_data(':ffff/ffff/ffff\027\\')
- screen:expect{any='did OptionSet, yay!'}
- feed_data(':echo "new_bg=".&background\n')
- screen:expect{any='new_bg=light'}
+ local child_server = new_pipename()
+ screen = thelpers.setup_child_nvim({
+ '--listen',
+ child_server,
+ -- Use --clean instead of -u NONE to load the osc52 plugin
+ '--clean',
+ }, {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+
+ -- Only queries when SSH_TTY is set
+ SSH_TTY = '/dev/pts/1',
+ },
+ })
- setup_bg_test()
- screen:expect([[
- {1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] 0,0-1 All}|
- |
- {3:-- TERMINAL --} |
- ]])
- -- Send a background response with the Pt portion split.
- feed_data('\027]11;rgba:ffff/fff')
- feed_data('f/ffff/8000\027\\')
- screen:expect{any='did OptionSet, yay!'}
+ screen:expect({ any = '%[No Name%]' })
- feed_data(':echo "new_bg=".&background\n')
- screen:expect{any='new_bg=light'}
+ local child_session = helpers.connect(child_server)
+ retry(nil, 1000, function()
+ eq('Ms', eval("get(g:, 'xtgettcap', '')"))
+ eq({ true, 'OSC 52' }, { child_session:request('nvim_eval', 'g:clipboard.name') })
+ end)
end)
+end)
- it('not triggers OptionSet event with invalid terminal-response', function()
- screen:expect([[
- {1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {5:[No Name] 0,0-1 All}|
- |
- {3:-- TERMINAL --} |
- ]])
- feed_data('\027]11;rgb:ffff/ffff/ffff/8000\027\\')
- screen:expect_unchanged()
+describe('TUI bg color', function()
+ before_each(clear)
+
+ it('is properly set in a nested Nvim instance when background=dark', function()
+ command('highlight clear Normal')
+ command('set background=dark') -- set outer Nvim background
+ local child_server = new_pipename()
+ local screen = thelpers.setup_child_nvim({
+ '--listen',
+ child_server,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set noswapfile',
+ })
+ screen:expect({ any = '%[No Name%]' })
+ local child_session = helpers.connect(child_server)
+ retry(nil, nil, function()
+ eq({ true, 'dark' }, { child_session:request('nvim_eval', '&background') })
+ end)
+ end)
- feed_data(':echo "new_bg=".&background\n')
- screen:expect{any='new_bg=dark'}
+ it('is properly set in a nested Nvim instance when background=light', function()
+ command('highlight clear Normal')
+ command('set background=light') -- set outer Nvim background
+ local child_server = new_pipename()
+ local screen = thelpers.setup_child_nvim({
+ '--listen',
+ child_server,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set noswapfile',
+ })
+ screen:expect({ any = '%[No Name%]' })
+ local child_session = helpers.connect(child_server)
+ retry(nil, nil, function()
+ eq({ true, 'light' }, { child_session:request('nvim_eval', '&background') })
+ end)
+ end)
+
+ it('queries the terminal for background color', function()
+ exec_lua([[
+ vim.api.nvim_create_autocmd('TermRequest', {
+ callback = function(args)
+ local req = args.data
+ if req == '\027]11;?' then
+ vim.g.oscrequest = true
+ return true
+ end
+ end,
+ })
+ ]])
+ thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set noswapfile',
+ })
+ retry(nil, 1000, function()
+ eq(true, eval("get(g:, 'oscrequest', v:false)"))
+ end)
+ end)
- setup_bg_test()
+ it('triggers OptionSet from automatic background processing', function()
+ local screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set noswapfile',
+ '-c',
+ 'autocmd OptionSet background echo "did OptionSet, yay!"',
+ })
screen:expect([[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {3:~} |*3
{5:[No Name] 0,0-1 All}|
- |
+ did OptionSet, yay! |
{3:-- TERMINAL --} |
]])
- feed_data('\027]11;rgba:ffff/foo/ffff/8000\027\\')
- screen:expect_unchanged()
-
- feed_data(':echo "new_bg=".&background\n')
- screen:expect{any='new_bg=dark'}
end)
end)
-- These tests require `thelpers` because --headless/--embed
-- does not initialize the TUI.
-describe("TUI as a client", function()
-
- it("connects to remote instance (with its own TUI)", function()
+describe('TUI as a client', function()
+ it('connects to remote instance (with its own TUI)', function()
local server_super = spawn_argv(false) -- equivalent to clear()
local client_super = spawn_argv(true)
set_session(server_super)
local server_pipe = new_pipename()
- local screen_server = thelpers.screen_setup(0,
- string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
- nvim_prog, server_pipe, nvim_set))
+ local screen_server = thelpers.setup_child_nvim({
+ '--listen',
+ server_pipe,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ nvim_set .. ' notermguicolors laststatus=2 background=dark',
+ })
- feed_data("iHello, World")
- screen_server:expect{grid=[[
+ feed_data('iHello, World')
+ screen_server:expect {
+ grid = [[
Hello, World{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
- ]]}
- feed_data("\027")
- screen_server:expect{grid=[[
+ ]],
+ }
+ feed_data('\027')
+ screen_server:expect {
+ grid = [[
Hello, Worl{1:d} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
set_session(client_super)
- local screen_client = thelpers.screen_setup(0,
- string.format([=[["%s", "--server", "%s", "--remote-ui"]]=],
- nvim_prog, server_pipe))
+ local screen_client = thelpers.setup_child_nvim({
+ '--server',
+ server_pipe,
+ '--remote-ui',
+ })
- screen_client:expect{grid=[[
+ screen_client:expect {
+ grid = [[
Hello, Worl{1:d} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
-- grid smaller than containing terminal window is cleared properly
feed_data(":call setline(1,['a'->repeat(&columns)]->repeat(&lines))\n")
- feed_data("0:set lines=3\n")
- screen_server:expect{grid=[[
+ feed_data('0:set lines=3\n')
+ screen_server:expect {
+ grid = [[
{1:a}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{5:[No Name] [+] }|
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
- feed_data(":q!\n")
+ feed_data(':q!\n')
server_super:close()
client_super:close()
end)
- it("connects to remote instance (--headless)", function()
+ it('connects to remote instance (--headless)', function()
local server = spawn_argv(false) -- equivalent to clear()
local client_super = spawn_argv(true)
set_session(server)
- local server_pipe = meths.get_vvar('servername')
+ local server_pipe = api.nvim_get_vvar('servername')
server:request('nvim_input', 'iHalloj!<Esc>')
+ server:request('nvim_command', 'set notermguicolors')
set_session(client_super)
- local screen_client = thelpers.screen_setup(0,
- string.format([=[["%s", "--server", "%s", "--remote-ui"]]=],
- nvim_prog, server_pipe))
+ local screen_client = thelpers.setup_child_nvim({
+ '--server',
+ server_pipe,
+ '--remote-ui',
+ })
- screen_client:expect{grid=[[
+ screen_client:expect {
+ grid = [[
Halloj{1:!} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*4
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
-- No heap-use-after-free when receiving UI events after deadly signal #22184
server:request('nvim_input', ('a'):rep(1000))
exec_lua([[vim.uv.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
- screen_client:expect{grid=[[
+ screen_client:expect {
+ grid = [[
Vim: Caught deadly signal 'SIGTERM' |
- |
- |
+ |*2
[Process exited 1]{1: } |
- |
- |
+ |*2
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
- eq(0, meths.get_vvar('shell_error'))
+ eq(0, api.nvim_get_vvar('shell_error'))
-- exits on input eof #22244
- funcs.system({nvim_prog, '--server', server_pipe, '--remote-ui'})
- eq(1, meths.get_vvar('shell_error'))
+ fn.system({ nvim_prog, '--server', server_pipe, '--remote-ui' })
+ eq(1, api.nvim_get_vvar('shell_error'))
client_super:close()
server:close()
end)
- it("throws error when no server exists", function()
+ it('throws error when no server exists', function()
clear()
- local screen = thelpers.screen_setup(0,
- string.format([=[["%s", "--server", "127.0.0.1:2436546", "--remote-ui"]]=],
- nvim_prog), 60)
+ local screen = thelpers.setup_child_nvim({
+ '--server',
+ '127.0.0.1:2436546',
+ '--remote-ui',
+ }, { cols = 60 })
screen:expect([[
Remote ui failed to start: {MATCH:.*}|
|
[Process exited 1]{1: } |
- |
- |
- |
+ |*3
{3:-- TERMINAL --} |
]])
end)
@@ -2813,89 +3116,98 @@ describe("TUI as a client", function()
set_session(server_super)
local server_pipe = new_pipename()
- local screen_server = thelpers.screen_setup(0,
- string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
- nvim_prog, server_pipe, nvim_set))
- screen_server:expect{grid=[[
+ local screen_server = thelpers.setup_child_nvim({
+ '--listen',
+ server_pipe,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ nvim_set .. ' notermguicolors laststatus=2 background=dark',
+ })
+ screen_server:expect {
+ grid = [[
{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
- feed_data("iHello, World")
- screen_server:expect{grid=[[
+ feed_data('iHello, World')
+ screen_server:expect {
+ grid = [[
Hello, World{1: } |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
- ]]}
- feed_data("\027")
- screen_server:expect{grid=[[
+ ]],
+ }
+ feed_data('\027')
+ screen_server:expect {
+ grid = [[
Hello, Worl{1:d} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
set_session(client_super)
- local screen_client = thelpers.screen_setup(0,
- string.format([=[["%s", "--server", "%s", "--remote-ui"]]=],
- nvim_prog, server_pipe))
+ local screen_client = thelpers.setup_child_nvim({
+ '--server',
+ server_pipe,
+ '--remote-ui',
+ })
- screen_client:expect{grid=[[
+ screen_client:expect {
+ grid = [[
Hello, Worl{1:d} |
- {4:~ }|
- {4:~ }|
- {4:~ }|
+ {4:~ }|*3
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
-- quitting the server
set_session(server_super)
- feed_data(status and ':' .. status .. 'cquit!\n' or ":quit!\n")
+ feed_data(status and ':' .. status .. 'cquit!\n' or ':quit!\n')
status = status and status or 0
- screen_server:expect{grid=[[
+ screen_server:expect {
+ grid = [[
|
[Process exited ]] .. status .. [[]{1: }{MATCH:%s+}|
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
-- assert that client has exited
- screen_client:expect{grid=[[
+ screen_client:expect {
+ grid = [[
|
[Process exited ]] .. status .. [[]{1: }{MATCH:%s+}|
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
- ]]}
+ ]],
+ }
server_super:close()
client_super:close()
end
- describe("exits when server quits", function()
- it("with :quit", function()
+ describe('exits when server quits', function()
+ it('with :quit', function()
test_remote_tui_quit()
end)
- it("with :cquit", function()
+ it('with :cquit', function()
test_remote_tui_quit(42)
end)
end)
diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua
index 39fc2c2562..3781933cad 100644
--- a/test/functional/terminal/window_spec.lua
+++ b/test/functional/terminal/window_spec.lua
@@ -22,13 +22,15 @@ describe(':terminal window', function()
skip(is_os('win'))
-- Test has hardcoded assumptions of dimensions.
eq(7, eval('&lines'))
- feed_data('\n\n\n') -- Add blank lines.
+ feed_data('\n\n\n') -- Add blank lines.
-- Terminal/shell contents must exceed the height of this window.
command('topleft 1split')
eq('terminal', eval('&buftype'))
feed([[i<cr>]])
-- Check topline _while_ in terminal-mode.
- retry(nil, nil, function() eq(6, eval('winsaveview()["topline"]')) end)
+ retry(nil, nil, function()
+ eq(6, eval('winsaveview()["topline"]'))
+ end)
end)
describe("with 'number'", function()
@@ -121,11 +123,7 @@ describe(':terminal window', function()
screen:expect([[
tty ready |
{2:^ } |
- |
- |
- |
- |
- |
+ |*5
]])
feed(':set colorcolumn=20<CR>i')
end)
@@ -134,10 +132,7 @@ describe(':terminal window', function()
screen:expect([[
tty ready |
{1: } |
- |
- |
- |
- |
+ |*4
{3:-- TERMINAL --} |
]])
end)
@@ -146,7 +141,7 @@ describe(':terminal window', function()
describe('with fold set', function()
before_each(function()
feed([[<C-\><C-N>:set foldenable foldmethod=manual<CR>i]])
- feed_data({'line1', 'line2', 'line3', 'line4', ''})
+ feed_data({ 'line1', 'line2', 'line3', 'line4', '' })
screen:expect([[
tty ready |
line1 |
@@ -179,54 +174,35 @@ describe(':terminal with multigrid', function()
before_each(function()
clear()
- screen = thelpers.screen_setup(0,nil,50,{ext_multigrid=true})
+ screen = thelpers.screen_setup(0, nil, 50, nil, { ext_multigrid = true })
end)
it('resizes to requested size', function()
screen:expect([[
## grid 1
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|*6
[3:--------------------------------------------------]|
## grid 2
tty ready |
{1: } |
- |
- |
- |
- |
+ |*4
## grid 3
{3:-- TERMINAL --} |
]])
screen:try_resize_grid(2, 20, 10)
if is_os('win') then
- screen:expect{any="rows: 10, cols: 20"}
+ screen:expect { any = 'rows: 10, cols: 20' }
else
screen:expect([[
## grid 1
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|*6
[3:--------------------------------------------------]|
## grid 2
tty ready |
rows: 10, cols: 20 |
{1: } |
- |
- |
- |
- |
- |
- |
- |
+ |*7
## grid 3
{3:-- TERMINAL --} |
]])
@@ -234,16 +210,11 @@ describe(':terminal with multigrid', function()
screen:try_resize_grid(2, 70, 3)
if is_os('win') then
- screen:expect{any="rows: 3, cols: 70"}
+ screen:expect { any = 'rows: 3, cols: 70' }
else
screen:expect([[
## grid 1
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|*6
[3:--------------------------------------------------]|
## grid 2
rows: 10, cols: 20 |
@@ -256,16 +227,11 @@ describe(':terminal with multigrid', function()
screen:try_resize_grid(2, 0, 0)
if is_os('win') then
- screen:expect{any="rows: 6, cols: 50"}
+ screen:expect { any = 'rows: 6, cols: 50' }
else
screen:expect([[
## grid 1
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
- [2:--------------------------------------------------]|
+ [2:--------------------------------------------------]|*6
[3:--------------------------------------------------]|
## grid 2
tty ready |
diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua
index da14531fa2..17411e2724 100644
--- a/test/functional/terminal/window_split_tab_spec.lua
+++ b/test/functional/terminal/window_split_tab_spec.lua
@@ -7,8 +7,8 @@ local feed_command = helpers.feed_command
local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
-local meths = helpers.meths
-local sleep = helpers.sleep
+local api = helpers.api
+local sleep = vim.uv.sleep
local retry = helpers.retry
local is_os = helpers.is_os
@@ -19,7 +19,7 @@ describe(':terminal', function()
clear()
-- set the statusline to a constant value because of variables like pid
-- and current directory and to improve visibility of splits
- meths.set_option_value('statusline', '==========', {})
+ api.nvim_set_option_value('statusline', '==========', {})
command('highlight StatusLine cterm=NONE')
command('highlight StatusLineNC cterm=NONE')
command('highlight VertSplit cterm=NONE')
@@ -35,7 +35,7 @@ describe(':terminal', function()
command('terminal')
command('vsplit foo')
eq(3, eval("winnr('$')"))
- feed('ZQ') -- Close split, should not crash. #7538
+ feed('ZQ') -- Close split, should not crash. #7538
assert_alive()
end)
@@ -50,8 +50,7 @@ describe(':terminal', function()
tty ready |
rows: 5, cols: 50 |
{2: } |
- |
- |
+ |*2
========== |
:2split |
]])
@@ -63,31 +62,23 @@ describe(':terminal', function()
^tty ready |
rows: 5, cols: 50 |
{2: } |
- |
- |
+ |*2
========== |
:wincmd p |
]])
end)
it('does not change size if updated when not visible in any window #19665', function()
- local channel = meths.get_option_value('channel', {})
+ local channel = api.nvim_get_option_value('channel', {})
command('enew')
sleep(100)
- meths.chan_send(channel, 'foo')
+ api.nvim_chan_send(channel, 'foo')
sleep(100)
command('bprevious')
screen:expect([[
tty ready |
^foo{2: } |
- |
- |
- |
- |
- |
- |
- |
- |
+ |*8
]])
end)
@@ -100,9 +91,9 @@ describe(':terminal', function()
-- win: SIGWINCH is unreliable, use a weaker test. #7506
retry(3, 30000, function()
screen:try_resize(w1, h1)
- screen:expect{any='rows: 7, cols: 47'}
+ screen:expect { any = 'rows: 7, cols: 47' }
screen:try_resize(w2, h2)
- screen:expect{any='rows: 4, cols: 41'}
+ screen:expect { any = 'rows: 4, cols: 41' }
end)
return
end
@@ -112,9 +103,7 @@ describe(':terminal', function()
tty ready |
rows: 7, cols: 47 |
{2: } |
- |
- |
- |
+ |*3
^ |
|
]])
@@ -133,8 +122,7 @@ describe(':terminal', function()
command('split')
command('terminal')
feed('a<Cmd>wincmd j<CR>')
- eq(2, eval("winnr()"))
+ eq(2, eval('winnr()'))
eq('t', eval('mode(1)'))
end)
-
end)