diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-10-25 09:59:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-25 09:59:02 +0800 |
commit | 684e93054b82c6b5b215db7d3ecbad803eb81f0e (patch) | |
tree | 4df579bfcad117e96b7546d5441c80cb62251280 /test/functional/terminal/channel_spec.lua | |
parent | 1094d0c0dbd0f37ccc0f1d18c73c6066e5690664 (diff) | |
download | rneovim-684e93054b82c6b5b215db7d3ecbad803eb81f0e.tar.gz rneovim-684e93054b82c6b5b215db7d3ecbad803eb81f0e.tar.bz2 rneovim-684e93054b82c6b5b215db7d3ecbad803eb81f0e.zip |
fix(terminal): assign channel to terminal earlier (#25771)
Diffstat (limited to 'test/functional/terminal/channel_spec.lua')
-rw-r--r-- | test/functional/terminal/channel_spec.lua | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua index 51bf611860..8510df5347 100644 --- a/test/functional/terminal/channel_spec.lua +++ b/test/functional/terminal/channel_spec.lua @@ -8,6 +8,10 @@ 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 async_meths = helpers.async_meths +local testprg = helpers.testprg +local assert_alive = helpers.assert_alive describe('terminal channel is closed and later released if', function() local screen @@ -116,3 +120,82 @@ it('chansend sends lines to terminal channel in proper order', function() } end end) + +describe('no crash when TermOpen autocommand', function() + local screen + + before_each(function() + clear() + meths.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}; + }) + 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=[[ + | + {0:~ }| + {0:~ }| + ^ | + ]]} + feed('<CR>') + screen:expect{grid=[[ + ^ready $ foobar | + | + [Process exited 0] | + | + ]]} + feed('i<CR>') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]]} + 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=[[ + | + {0:~ }| + {0:~ }| + ^ | + ]]} + feed('<CR>') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]]} + 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=[[ + | + {0:~ }| + {0:~ }| + ^ | + ]]} + feed('<CR>') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]]} + assert_alive() + end) +end) |