From 16d4af6d2f549709aa55510f5ae52238c5cadb9c Mon Sep 17 00:00:00 2001 From: Sebastian Lyng Johansen Date: Sun, 7 Nov 2021 16:13:53 +0100 Subject: feat(ui): add vim.ui.input and use in lsp rename (#15959) * vim.ui.input is an overridable function that prompts for user input * take an opts table and the `on_confirm` callback, see `:help vim.ui.input` for more details * defaults to a wrapper around vim.fn.input(opts) * switches the built-in client's rename handler to use vim.ui.input by default --- test/functional/lua/ui_spec.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/functional/lua/ui_spec.lua') diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua index 94f1b5840b..2371939204 100644 --- a/test/functional/lua/ui_spec.lua +++ b/test/functional/lua/ui_spec.lua @@ -43,4 +43,29 @@ describe('vim.ui', function() }, result[2]) end) end) + + describe('input', function() + it('can input text', function() + local result = exec_lua[[ + local opts = { + prompt = 'Input: ', + } + local input + local cb = function(item) + input = item + end + -- input would require input and block the test; + local prompt + vim.fn.input = function(opts) + prompt = opts.prompt + return "Inputted text" + end + vim.ui.input(opts, cb) + vim.wait(100, function() return input ~= nil end) + return {input, prompt} + ]] + eq('Inputted text', result[1]) + eq('Input: ', result[2]) + end) + end) end) -- cgit