feat(ui): use vim.ui.select for :tselect, z= #39478

Problem:
`:tselect` and `z=` (spell suggest) have their own bespoke select menus.

Solution:
- Delegate to `vim.ui.select` instead.
- Bonus:
  - `:tselect` gains mouse support. `print_tag_list` didn't suport mouseclick.

This causes some minor regressions, which are not blockers:

- `z=` no longer draws the list right-left if 'rightleft' is set.
  - TODO: can/should `vim.ui.select` / `vim.fn.inputlist()` handle that?
- `:tselect`
  - No "column" headings (`# pri kind tag file`).
  - No highlighting: (HLF_T: tag name, HLF_D: file, HLF_CM: extra fields).
  - TODO: can `vim.ui.select()` support highlighted chunks (`[[text, hl_id], ...]`) ?

fix https://github.com/neovim/neovim/issues/25814
fix https://github.com/neovim/neovim/issues/31987
This commit is contained in:
Justin M. Keyes
2026-04-28 18:29:17 -04:00
committed by GitHub
parent 33ea63011c
commit 55ceb314ca
14 changed files with 431 additions and 339 deletions

View File

@@ -2,7 +2,6 @@ local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local pcall_err = t.pcall_err
local ok = t.ok
local exec_lua = n.exec_lua
local clear = n.clear
@@ -17,41 +16,6 @@ describe('vim.ui', function()
clear({ args_rm = { '-u' }, args = { '--clean' } })
end)
describe('select()', function()
it('can select an item', function()
local result = exec_lua [[
local items = {
{ name = 'Item 1' },
{ name = 'Item 2' },
}
local opts = {
format_item = function(entry)
return entry.name
end
}
local selected
local cb = function(item)
selected = item
end
-- inputlist would require input and block the test;
local choices
vim.fn.inputlist = function(x)
choices = x
return 1
end
vim.ui.select(items, opts, cb)
vim.wait(100, function() return selected ~= nil end)
return {selected, choices}
]]
eq({ name = 'Item 1' }, result[1])
eq({
'Select one of:',
'1: Item 1',
'2: Item 2',
}, result[2])
end)
end)
describe('input()', function()
it('can input text', function()
local result = exec_lua [[