From 9ca7b6b71a1e98ff6a76270d165fc8f07763a0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fu=C3=9Fenegger?= Date: Tue, 28 Sep 2021 01:12:03 +0200 Subject: [PATCH] fix(ui): s/format_entry/format_item to match docs (#15819) Follow up to https://github.com/neovim/neovim/pull/15771 --- runtime/lua/vim/lsp/handlers.lua | 2 +- runtime/lua/vim/ui.lua | 4 ++-- test/functional/lua/ui_spec.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 538bd2605b..def83a7320 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -149,7 +149,7 @@ M['textDocument/codeAction'] = function(_, result, ctx) vim.ui.select(result, { prompt = 'Code actions:', - format_entry = function(action) + format_item = function(action) local title = action.title:gsub('\r\n', '\\r\\n') return title:gsub('\n', '\\n') end, diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index aebb63d56f..5eab20fc54 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -20,9 +20,9 @@ function M.select(items, opts, on_choice) } opts = opts or {} 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 - table.insert(choices, string.format('%d: %s', i, format_entry(item))) + table.insert(choices, string.format('%d: %s', i, format_item(item))) end local choice = vim.fn.inputlist(choices) if choice < 1 or choice > #items then diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua index 25a208b70b..94f1b5840b 100644 --- a/test/functional/lua/ui_spec.lua +++ b/test/functional/lua/ui_spec.lua @@ -17,7 +17,7 @@ describe('vim.ui', function() { name = 'Item 2' }, } local opts = { - format_entry = function(entry) + format_item = function(entry) return entry.name end }