fix(ui): s/format_entry/format_item to match docs (#15819)

Follow up to https://github.com/neovim/neovim/pull/15771
This commit is contained in:
Mathias Fußenegger
2021-09-28 01:12:03 +02:00
committed by GitHub
parent 63fde086d9
commit 9ca7b6b71a
3 changed files with 4 additions and 4 deletions

View File

@@ -149,7 +149,7 @@ M['textDocument/codeAction'] = function(_, result, ctx)
vim.ui.select(result, { vim.ui.select(result, {
prompt = 'Code actions:', prompt = 'Code actions:',
format_entry = function(action) format_item = function(action)
local title = action.title:gsub('\r\n', '\\r\\n') local title = action.title:gsub('\r\n', '\\r\\n')
return title:gsub('\n', '\\n') return title:gsub('\n', '\\n')
end, end,

View File

@@ -20,9 +20,9 @@ function M.select(items, opts, on_choice)
} }
opts = opts or {} opts = opts or {}
local choices = {opts.prompt or 'Select one of:'} local choices = {opts.prompt or 'Select one of:'}
local format_entry = opts.format_entry or tostring local format_item = opts.format_item or tostring
for i, item in pairs(items) do for i, item in pairs(items) do
table.insert(choices, string.format('%d: %s', i, format_entry(item))) table.insert(choices, string.format('%d: %s', i, format_item(item)))
end end
local choice = vim.fn.inputlist(choices) local choice = vim.fn.inputlist(choices)
if choice < 1 or choice > #items then if choice < 1 or choice > #items then

View File

@@ -17,7 +17,7 @@ describe('vim.ui', function()
{ name = 'Item 2' }, { name = 'Item 2' },
} }
local opts = { local opts = {
format_entry = function(entry) format_item = function(entry)
return entry.name return entry.name
end end
} }