aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/ex_terminal_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
commit931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch)
treed8c1843a95da5ea0bb4acc09f7e37843d9995c86 /test/functional/terminal/ex_terminal_spec.lua
parent142d9041391780ac15b89886a54015fdc5c73995 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-userreg.tar.gz
rneovim-userreg.tar.bz2
rneovim-userreg.zip
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'test/functional/terminal/ex_terminal_spec.lua')
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua59
1 files changed, 41 insertions, 18 deletions
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 6b7e93a864..f628e261a2 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -99,7 +99,7 @@ describe(':terminal', function()
end)
it('nvim_get_mode() in :terminal', function()
- command(':terminal')
+ command('terminal')
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
feed('i')
eq({ blocking=false, mode='t' }, nvim('get_mode'))
@@ -108,21 +108,37 @@ describe(':terminal', function()
end)
it(':stopinsert RPC request exits terminal-mode #7807', function()
- command(':terminal')
+ command('terminal')
feed('i[tui] insert-mode')
eq({ blocking=false, mode='t' }, nvim('get_mode'))
command('stopinsert')
+ feed('<Ignore>') -- Add input to separate two RPC requests
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
end)
it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
- command(':terminal')
+ command('terminal')
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
- command(':stopinsert')
+ command('stopinsert')
+ feed('<Ignore>') -- Add input to separate two RPC requests
eq({ blocking=false, mode='nt' }, nvim('get_mode'))
feed('a')
eq({ blocking=false, mode='t' }, nvim('get_mode'))
end)
+
+ it('switching to terminal buffer in Insert mode goes to Terminal mode #7164', function()
+ command('terminal')
+ command('vnew')
+ feed('i')
+ command('let g:events = []')
+ 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'))
+ feed('<F2>')
+ eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ eq({'InsertLeave', 'TermEnter'}, eval('g:events'))
+ end)
end)
describe(':terminal (with fake shell)', function()
@@ -133,31 +149,37 @@ describe(':terminal (with fake shell)', function()
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', 'shell', testprg('shell-test'))
- nvim('set_option', 'shellcmdflag', 'EXE')
+ nvim('set_option_value', 'shell', testprg('shell-test'), {})
+ nvim('set_option_value', 'shellcmdflag', 'EXE', {})
+ nvim('set_option_value', 'shellxquote', '', {})
end)
-- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints
- -- the {cmd} and exits immediately .
+ -- 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'))
- terminal_with_fake_shell()
+ -- 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()
screen:expect([[
- ^ready $ |
- [Process exited 0] |
+ ^ |
+ [Process exited 1] |
|
- :terminal |
+ :terminal 1 |
]])
end)
end)
it("with no argument, and 'shell' is set to empty string", function()
- nvim('set_option', 'shell', '')
+ nvim('set_option_value', 'shell', '', {})
terminal_with_fake_shell()
screen:expect([[
^ |
@@ -169,7 +191,7 @@ describe(':terminal (with fake shell)', function()
it("with no argument, but 'shell' has arguments, acts like termopen()", function()
skip(is_os('win'))
- nvim('set_option', 'shell', testprg('shell-test')..' -t jeff')
+ nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {})
terminal_with_fake_shell()
screen:expect([[
^jeff $ |
@@ -193,7 +215,7 @@ describe(':terminal (with fake shell)', function()
it("executes a given command through the shell, when 'shell' has arguments", function()
skip(is_os('win'))
- nvim('set_option', 'shell', testprg('shell-test')..' -t jeff')
+ nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {})
command('set shellxquote=') -- win: avoid extra quotes
terminal_with_fake_shell('echo hi')
screen:expect([[
@@ -243,12 +265,13 @@ describe(':terminal (with fake shell)', function()
it('works with :find', function()
skip(is_os('win'))
- terminal_with_fake_shell()
+ nvim('set_option_value', 'shellcmdflag', 'EXIT', {})
+ terminal_with_fake_shell(1)
screen:expect([[
- ^ready $ |
- [Process exited 0] |
+ ^ |
+ [Process exited 1] |
|
- :terminal |
+ :terminal 1 |
]])
eq('term://', string.match(eval('bufname("%")'), "^term://"))
feed([[<C-\><C-N>]])