aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/tui_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-09-18 04:14:06 -0700
committerGitHub <noreply@github.com>2024-09-18 04:14:06 -0700
commitff85e54939b0aca34a779a2b6381d09db1858b29 (patch)
treeeea30db8b69582af6c206b1a8ac0b4918fc61e20 /test/functional/terminal/tui_spec.lua
parent22553e1f38addd867ad659b2944d00129141a499 (diff)
downloadrneovim-ff85e54939b0aca34a779a2b6381d09db1858b29.tar.gz
rneovim-ff85e54939b0aca34a779a2b6381d09db1858b29.tar.bz2
rneovim-ff85e54939b0aca34a779a2b6381d09db1858b29.zip
feat(tui): builtin UI (TUI) sets client info #30397
Problem: The default builtin UI client does not declare its client info. This reduces discoverability and makes it difficult for plugins to identify the UI. Solution: - Call nvim_set_client_info after attaching, as recommended by `:help dev-ui`. - Also set the "pid" field. - Also change `ui_active()` to return a count. Not directly relevant to this commit, but will be useful later.
Diffstat (limited to 'test/functional/terminal/tui_spec.lua')
-rw-r--r--test/functional/terminal/tui_spec.lua46
1 files changed, 42 insertions, 4 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 6375e6fbae..3e837e796d 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -40,8 +40,8 @@ if t.skip(is_os('win')) then
end
describe('TUI', function()
- local screen
- local child_session
+ local screen --[[@type test.functional.ui.screen]]
+ local child_session --[[@type test.Session]]
local child_exec_lua
before_each(function()
@@ -1651,12 +1651,13 @@ describe('TUI', function()
]])
end)
- it('in nvim_list_uis()', function()
+ it('in nvim_list_uis(), sets nvim_set_client_info()', function()
-- $TERM in :terminal.
local exp_term = is_os('bsd') and 'builtin_xterm' or 'xterm-256color'
+ local ui_chan = 1
local expected = {
{
- chan = 1,
+ chan = ui_chan,
ext_cmdline = false,
ext_hlstate = false,
ext_linegrid = true,
@@ -1679,6 +1680,43 @@ describe('TUI', function()
}
local _, rv = child_session:request('nvim_list_uis')
eq(expected, rv)
+
+ ---@type table
+ local expected_version = ({
+ child_session:request('nvim_exec_lua', 'return vim.version()', {}),
+ })[2]
+ -- vim.version() returns `prerelease` string. Coerce it to boolean.
+ expected_version.prerelease = not not expected_version.prerelease
+
+ local expected_chan_info = {
+ client = {
+ attributes = {
+ license = 'Apache 2',
+ -- pid = 5371,
+ website = 'https://neovim.io',
+ },
+ methods = {},
+ name = 'nvim-tui',
+ type = 'ui',
+ version = expected_version,
+ },
+ id = ui_chan,
+ mode = 'rpc',
+ stream = 'stdio',
+ }
+
+ local status, chan_info = child_session:request('nvim_get_chan_info', ui_chan)
+ ok(status)
+ local info = chan_info.client
+ ok(info.attributes.pid and info.attributes.pid > 0, 'PID', info.attributes.pid or 'nil')
+ ok(info.version.major >= 0)
+ ok(info.version.minor >= 0)
+ ok(info.version.patch >= 0)
+
+ -- Delete variable fields so we can deep-compare.
+ info.attributes.pid = nil
+
+ eq(expected_chan_info, chan_info)
end)
it('allows grid to assume wider ambiwidth chars than host terminal', function()