I found some inconsistencies using vim.ui.select
If it called like this
vim.ui.select({ 'something1', 'something2', nil }, { prompt = 'select' }, function(item, idx)
utils.notify('item = ' .. tostring(item) .. ' and index = ' .. idx)
end)
There is gonna be 2 items available for selection.
But if I use format_item
function which is gonna return nil for one of items
local format = function(item)
if item == 'something3' then
return nil
end
return item
end
vim.ui.select({ 'something1', 'something2', 'something3' }, { prompt = 'select', format_item = format }, function(item, idx)
utils.notify('item = ' .. tostring(item) .. ' and index = ' .. idx)
end)
Then result will contain nil value (see ‘something3’ and format function. Here is also a problem with number of results when using telescope-ui-select. See 3 / 3
when there is only 2 available options.
Screenshot:
I think, that vim.ui.select
should not use an item in selection, if format_item(item) == nil
. Just like it discards items which are nil. What do you think?