diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2024-01-28 07:37:57 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-28 07:37:57 -0600 |
commit | 6d86a6fe444a34dc0c70319c8056ff0161c4d319 (patch) | |
tree | 879fd160b250298137976d5ee05bc33bc4ae4255 | |
parent | a757195a602bf502fcdb702887bf72f50d6e1717 (diff) | |
download | rneovim-6d86a6fe444a34dc0c70319c8056ff0161c4d319.tar.gz rneovim-6d86a6fe444a34dc0c70319c8056ff0161c4d319.tar.bz2 rneovim-6d86a6fe444a34dc0c70319c8056ff0161c4d319.zip |
test(tui): add & improve tests for terminal queries (#27219)
Problems:
1. The test case for querying truecolor support did not check which
capabilities were queried
2. The test case for querying truecolor support checked `&termguicolors`
in the Nvim test runner, not the child Nvim in the the embedded
terminal
3. The test case for querying truecolor support did not actually respond
to the XTGETTCAP requests. `'termguicolors'` is still enabled even
without responding to this query because libvterm understands and
responds to the DECRQSS request, but it is still good to respond to
the query explicitly instead of depending on hidden libvterm behavior
4. No test case exists at all for OSC 52
Solution:
Fix all of the problems listed above.
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 06285d91b5..121664ae84 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -2777,13 +2777,23 @@ describe('TUI', function() local req = args.data local payload = req:match('^\027P%+q([%x;]+)$') if payload then - vim.g.xtgettcap = true + local t = {} + for cap in vim.gsplit(payload, ';') do + local resp = string.format('\027P1+r%s\027\\', payload) + vim.api.nvim_chan_send(vim.bo[args.buf].channel, resp) + t[vim.text.hexdecode(cap)] = true + end + vim.g.xtgettcap = t return true end end, }) ]]) + + local child_server = new_pipename() screen = thelpers.setup_child_nvim({ + '--listen', + child_server, '-u', 'NONE', '-i', @@ -2799,9 +2809,58 @@ describe('TUI', function() }, }) + screen:expect({ any = '%[No Name%]' }) + + local child_session = helpers.connect(child_server) + retry(nil, 1000, function() + eq({ + Tc = true, + RGB = true, + setrgbf = true, + setrgbb = true, + }, eval("get(g:, 'xtgettcap', '')")) + eq({ true, 1 }, { child_session:request('nvim_eval', '&termguicolors') }) + end) + end) + + it('queries the terminal for OSC 52 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 and vim.text.hexdecode(payload) == 'Ms' then + vim.g.xtgettcap = 'Ms' + local resp = string.format('\027P1+r%s=%s\027\\', payload, vim.text.hexencode('\027]52;;\027\\')) + vim.api.nvim_chan_send(vim.bo[args.buf].channel, resp) + return true + end + end, + }) + ]]) + + local child_server = new_pipename() + screen = thelpers.setup_child_nvim({ + '--listen', + child_server, + -- Use --clean instead of -u NONE to load the osc52 plugin + '--clean', + }, { + env = { + VIMRUNTIME = os.getenv('VIMRUNTIME'), + + -- Only queries when SSH_TTY is set + SSH_TTY = '/dev/pts/1', + }, + }) + + screen:expect({ any = '%[No Name%]' }) + + local child_session = helpers.connect(child_server) retry(nil, 1000, function() - eq(true, eval("get(g:, 'xtgettcap', v:false)")) - eq(1, eval('&termguicolors')) + eq('Ms', eval("get(g:, 'xtgettcap', '')")) + eq({ true, 'OSC 52' }, { child_session:request('nvim_eval', 'g:clipboard.name') }) end) end) end) |