fix!: update vim.ui.input to match nvim 0.9 API
https://github.com/neovim/neovim/pull/20883 changed the behavior of vim.ui.input. The main change was that inputting no text now returns an empty string instead of nil.
This commit is contained in:
parent
2319ee2397
commit
202bcf6bdb
|
@ -97,9 +97,6 @@ local function confirm(text)
|
|||
-- deleted from the buffer after the input window closes.
|
||||
vim.defer_fn(function()
|
||||
pcall(vim.api.nvim_win_close, ctx.winid, true)
|
||||
if text == "" then
|
||||
text = nil
|
||||
end
|
||||
if text and history[#history] ~= text then
|
||||
table.insert(history, text)
|
||||
end
|
||||
|
|
|
@ -78,6 +78,28 @@ a.describe("input modal", function()
|
|||
assert(ret == "my text", string.format("Got '%s' expected 'my text'", ret))
|
||||
end)
|
||||
|
||||
a.it("returns cancelreturn when input is canceled <C-c>", function()
|
||||
local ret = run_input({
|
||||
"my text",
|
||||
"<C-c>",
|
||||
}, { cancelreturn = "CANCELED" })
|
||||
assert(ret == "CANCELED", string.format("Got '%s' expected nil", ret))
|
||||
end)
|
||||
|
||||
a.it("returns empty string when input is empty", function()
|
||||
local ret = run_input({
|
||||
"<CR>",
|
||||
})
|
||||
assert(ret == "", string.format("Got '%s' expected nil", ret))
|
||||
end)
|
||||
|
||||
a.it("returns empty string when input is empty, even if cancelreturn set", function()
|
||||
local ret = run_input({
|
||||
"<CR>",
|
||||
}, { cancelreturn = "CANCELED" })
|
||||
assert(ret == "", string.format("Got '%s' expected nil", ret))
|
||||
end)
|
||||
|
||||
a.it("starts in normal mode when start_in_insert = false", function()
|
||||
local orig_cmd = vim.cmd
|
||||
local startinsert_called = false
|
||||
|
|
Loading…
Reference in New Issue