aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/buffer_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal/buffer_spec.lua')
-rw-r--r--test/functional/terminal/buffer_spec.lua44
1 files changed, 40 insertions, 4 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 7dcca231ee..1cef771f0d 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -6,9 +6,11 @@ local poke_eventloop = helpers.poke_eventloop
local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source
local eq, neq = helpers.eq, helpers.neq
local write_file = helpers.write_file
-local command= helpers.command
+local command = helpers.command
local exc_exec = helpers.exc_exec
local matches = helpers.matches
+local exec_lua = helpers.exec_lua
+local sleep = helpers.sleep
describe(':terminal buffer', function()
local screen
@@ -256,6 +258,7 @@ describe(':terminal buffer', function()
end)
it('it works with set rightleft #11438', function()
+ if helpers.pending_win32(pending) then return end
local columns = eval('&columns')
feed(string.rep('a', columns))
command('set rightleft')
@@ -290,10 +293,9 @@ describe(':terminal buffer', function()
command('quit')
end)
- it('does not segfault when pasting empty buffer #13955', function()
- feed_command('terminal')
+ it('does not segfault when pasting empty register #13955', function()
feed('<c-\\><c-n>')
- feed_command('put a') -- buffer a is empty
+ feed_command('put a') -- register a is empty
helpers.assert_alive()
end)
end)
@@ -328,3 +330,37 @@ describe('No heap-buffer-overflow when', function()
assert_alive()
end)
end)
+
+describe('on_lines does not emit out-of-bounds line indexes when', function()
+ before_each(function()
+ clear()
+ exec_lua([[
+ function _G.register_callback(bufnr)
+ _G.cb_error = ''
+ vim.api.nvim_buf_attach(bufnr, false, {
+ on_lines = function(_, bufnr, _, firstline, _, _)
+ local status, msg = pcall(vim.api.nvim_buf_get_offset, bufnr, firstline)
+ if not status then
+ _G.cb_error = msg
+ end
+ end
+ })
+ end
+ ]])
+ end)
+
+ it('creating a terminal buffer #16394', function()
+ feed_command('autocmd TermOpen * ++once call v:lua.register_callback(str2nr(expand("<abuf>")))')
+ feed_command('terminal')
+ sleep(500)
+ eq('', exec_lua([[return _G.cb_error]]))
+ end)
+
+ it('deleting a terminal buffer #16394', function()
+ feed_command('terminal')
+ sleep(500)
+ feed_command('lua _G.register_callback(0)')
+ feed_command('bdelete!')
+ eq('', exec_lua([[return _G.cb_error]]))
+ end)
+end)