aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-07-23 08:53:59 +0800
committerGitHub <noreply@github.com>2023-07-23 08:53:59 +0800
commitf0d618667a8a460b2c6135da19c74f0a4ad52128 (patch)
treec1f90b1b648685b3f223f83530da9ec5aafda017
parentcdb758ef447e1f934966fab42d5db0bf929de89c (diff)
downloadrneovim-f0d618667a8a460b2c6135da19c74f0a4ad52128.tar.gz
rneovim-f0d618667a8a460b2c6135da19c74f0a4ad52128.tar.bz2
rneovim-f0d618667a8a460b2c6135da19c74f0a4ad52128.zip
test: check that TextChangedT cannot delete terminal buffer (#24437)
-rw-r--r--test/functional/autocmd/termxx_spec.lua20
-rw-r--r--test/functional/terminal/buffer_spec.lua8
2 files changed, 20 insertions, 8 deletions
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua
index 9ec1469c03..359203f945 100644
--- a/test/functional/autocmd/termxx_spec.lua
+++ b/test/functional/autocmd/termxx_spec.lua
@@ -1,5 +1,6 @@
local luv = require('luv')
local helpers = require('test.functional.helpers')(after_each)
+local thelpers = require('test.functional.terminal.helpers')
local clear, command, nvim, testprg =
helpers.clear, helpers.command, helpers.nvim, helpers.testprg
@@ -8,6 +9,7 @@ local eval, eq, neq, retry =
local matches = helpers.matches
local ok = helpers.ok
local feed = helpers.feed
+local meths = helpers.meths
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
local skip = helpers.skip
@@ -162,3 +164,21 @@ it('autocmd TermEnter, TermLeave', function()
},
eval('g:evs'))
end)
+
+describe('autocmd TextChangedT', function()
+ clear()
+ local screen = thelpers.screen_setup()
+
+ it('works', function()
+ command('autocmd TextChangedT * ++once let g:called = 1')
+ thelpers.feed_data('a')
+ retry(nil, nil, function() eq(1, meths.get_var('called')) end)
+ end)
+
+ it('cannot delete terminal buffer', function()
+ command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
+ thelpers.feed_data('a')
+ screen:expect({any = 'E937: '})
+ matches('^E937: Attempt to delete a buffer that is in use: term://', meths.get_vvar('errmsg'))
+ end)
+end)
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 3bc03a4117..9b690bed74 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -414,14 +414,6 @@ describe('on_lines does not emit out-of-bounds line indexes when', function()
feed_command('bdelete!')
eq('', exec_lua([[return _G.cb_error]]))
end)
-
- it('runs TextChangedT event', function()
- meths.set_var('called', 0)
- command('autocmd TextChangedT * ++once let g:called = 1')
- feed_command('terminal')
- feed('iaa')
- eq(1, meths.get_var('called'))
- end)
end)
it('terminal truncates number of composing characters to 5', function()