aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/buffer_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:29 +0100
commit04f2f864e270e772c6326cefdf24947f0130e492 (patch)
tree46f83f909b888a66c741032ab955afc6eab84292 /test/functional/terminal/buffer_spec.lua
parent59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff)
downloadrneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip
refactor: format test/*
Diffstat (limited to 'test/functional/terminal/buffer_spec.lua')
-rw-r--r--test/functional/terminal/buffer_spec.lua178
1 files changed, 127 insertions, 51 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 02958a69e0..480ca96289 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -32,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()
@@ -170,9 +176,7 @@ describe(':terminal buffer', function()
-- 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
@@ -180,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.
]])
@@ -197,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)
@@ -212,18 +216,18 @@ 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)
@@ -243,11 +247,15 @@ describe(':terminal buffer', function()
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]'))
@@ -264,42 +272,50 @@ 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))
feed [[<c-\><c-o>]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
tty ready |
{2:^ } |
|*4
{3:-- (terminal) --} |
- ]]}
+ ]],
+ }
eq('ntT', funcs.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))
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)
end)
@@ -307,7 +323,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()
@@ -373,7 +389,9 @@ it('terminal truncates number of composing characters to 5', function()
local chan = meths.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)
+ retry(nil, nil, function()
+ eq('a' .. composing:rep(5), meths.get_current_line())
+ end)
end)
describe('terminal input', function()
@@ -404,33 +422,79 @@ describe('terminal input', function()
it('sends various special keys with modifiers', function()
clear()
local screen = thelpers.setup_child_nvim({
- '-u', 'NONE',
- '-i', 'NONE',
- '--cmd', 'colorscheme vim',
- '--cmd', 'set notermguicolors',
- '--cmd', 'startinsert',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'colorscheme vim',
+ '--cmd',
+ 'set notermguicolors',
+ '--cmd',
+ 'startinsert',
})
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: } |
{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, meths.get_current_line())
+ end)
end
end)
end)
@@ -443,7 +507,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)
@@ -508,16 +572,22 @@ 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(funcs.termopen, "bar"))
+ feed('q:')
+ eq(
+ 'Vim:E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
+ pcall_err(funcs.termopen, 'bar')
+ )
end)
describe('$COLORTERM value', function()
- if skip(is_os('win'), 'Not applicable for Windows') then return end
+ if skip(is_os('win'), 'Not applicable for Windows') then
+ return
+ end
before_each(function()
-- Outer value should never be propagated to :terminal
@@ -528,8 +598,14 @@ describe('termopen()', function()
local screen = Screen.new(50, 4)
screen:attach()
funcs.termopen({
- nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless',
- '-c', 'echo $COLORTERM | quit',
+ nvim_prog,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--headless',
+ '-c',
+ 'echo $COLORTERM | quit',
}, opts)
screen:expect(([[
^%s{MATCH:%%s+}|