aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/tui_spec.lua
diff options
context:
space:
mode:
authorGhjuvan Lacambre <code@lacamb.re>2024-01-09 15:27:56 +0100
committerGitHub <noreply@github.com>2024-01-09 08:27:56 -0600
commitbeca827212b106114c371f8bb61aa1a50810062f (patch)
tree8c48282193fef8f58768a03663df94bf00b8aa29 /test/functional/terminal/tui_spec.lua
parentf40df63bdca33d343cada6ceaafbc8b765ed7cc6 (diff)
downloadrneovim-beca827212b106114c371f8bb61aa1a50810062f.tar.gz
rneovim-beca827212b106114c371f8bb61aa1a50810062f.tar.bz2
rneovim-beca827212b106114c371f8bb61aa1a50810062f.zip
feat(terminal): trigger TermRequest autocommand events (#22159)
This commit implements a new TermRequest autocommand event and has Neovim emit this event when children of terminal buffers emit an OSC or DCS sequence libvterm does not handle. The TermRequest autocommand event has additional data in the v:termrequest variable. Co-authored-by: Gregory Anders <greg@gpanders.com>
Diffstat (limited to 'test/functional/terminal/tui_spec.lua')
-rw-r--r--test/functional/terminal/tui_spec.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index f6ee0f9c77..e65e57bc7f 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -28,6 +28,7 @@ local new_pipename = helpers.new_pipename
local spawn_argv = helpers.spawn_argv
local set_session = helpers.set_session
local write_file = helpers.write_file
+local eval = helpers.eval
if helpers.skip(is_os('win')) then
return
@@ -2736,6 +2737,42 @@ describe('TUI', function()
unchanged = true,
}
end)
+
+ it('queries the terminal for truecolor support', function()
+ clear()
+ exec_lua([[
+ vim.api.nvim_create_autocmd('TermRequest', {
+ callback = function(args)
+ local req = args.data
+ local payload = req:match('^\027P%+q([%x;]+)$')
+ if payload then
+ vim.g.xtgettcap = true
+ return true
+ end
+ end,
+ })
+ ]])
+ screen = thelpers.setup_child_nvim({
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ }, {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+
+ -- Force COLORTERM to be unset and use a TERM that does not contain Tc or RGB in terminfo.
+ -- This will force the nested nvim instance to query with XTGETTCAP
+ COLORTERM = '',
+ TERM = 'xterm-256colors',
+ },
+ })
+
+ retry(nil, 1000, function()
+ eq(true, eval("get(g:, 'xtgettcap', v:false)"))
+ eq(1, eval('&termguicolors'))
+ end)
+ end)
end)
describe('TUI bg color', function()
@@ -2743,6 +2780,18 @@ describe('TUI bg color', function()
local function setup_bg_test()
clear()
+ exec_lua([[
+ vim.api.nvim_create_autocmd('TermRequest', {
+ callback = function(args)
+ local req = args.data
+ if req == '\027]11;?' then
+ vim.g.oscrequest = true
+ return true
+ end
+ end,
+ })
+ ]])
+
screen = thelpers.setup_child_nvim({
'-u',
'NONE',
@@ -2759,6 +2808,12 @@ describe('TUI bg color', function()
before_each(setup_bg_test)
+ it('queries the terminal for background color', function()
+ retry(nil, 1000, function()
+ eq(true, eval("get(g:, 'oscrequest', v:false)"))
+ end)
+ end)
+
it('triggers OptionSet event on unsplit terminal-response', function()
screen:expect([[
{1: } |