diff options
author | Sebastian Lyng Johansen <seblyng98@gmail.com> | 2021-11-07 16:13:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-07 07:13:53 -0800 |
commit | 16d4af6d2f549709aa55510f5ae52238c5cadb9c (patch) | |
tree | 69737a428f78aa7f7df1540038c5d6d463d3e875 /test/functional/lua/ui_spec.lua | |
parent | b74916cfd21fc307ad4898a519e1407411a01ba5 (diff) | |
download | rneovim-16d4af6d2f549709aa55510f5ae52238c5cadb9c.tar.gz rneovim-16d4af6d2f549709aa55510f5ae52238c5cadb9c.tar.bz2 rneovim-16d4af6d2f549709aa55510f5ae52238c5cadb9c.zip |
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
Diffstat (limited to 'test/functional/lua/ui_spec.lua')
-rw-r--r-- | test/functional/lua/ui_spec.lua | 25 |
1 files changed, 25 insertions, 0 deletions
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) |