fix(terminal): block input when there is pending TermRequest (#27589)

This commit is contained in:
zeertzjq
2024-02-24 05:12:30 +08:00
committed by GitHub
parent cb5ae22eab
commit 99288ecc77
2 changed files with 70 additions and 9 deletions

View File

@@ -319,8 +319,7 @@ describe(':terminal buffer', function()
end)
it('emits TermRequest events #26972', function()
command('split')
command('enew')
command('new')
local term = api.nvim_open_term(0, {})
local termbuf = api.nvim_get_current_buf()
@@ -336,6 +335,35 @@ describe(':terminal buffer', function()
eq(expected, eval('v:termrequest'))
eq(termbuf, eval('g:termbuf'))
end)
it('TermReqeust synchronization #27572', function()
command('new')
command('autocmd! nvim_terminal TermRequest')
local term = exec_lua([[
_G.input = {}
local term = vim.api.nvim_open_term(0, {
on_input = function(_, _, _, data)
table.insert(_G.input, data)
end,
force_crlf = false,
})
vim.api.nvim_create_autocmd('TermRequest', {
callback = function(args)
if args.data == '\027]11;?' then
table.insert(_G.input, '\027]11;rgb:0000/0000/0000\027\\')
end
end
})
return term
]])
api.nvim_chan_send(term, '\027]11;?\007\027[5n\027]11;?\007\027[5n')
eq({
'\027]11;rgb:0000/0000/0000\027\\',
'\027[0n',
'\027]11;rgb:0000/0000/0000\027\\',
'\027[0n',
}, exec_lua('return _G.input'))
end)
end)
describe('No heap-buffer-overflow when using', function()