Merge pull request #49 from mbenford/start-in-normal-mode
Add start_in_insert option
This commit is contained in:
commit
9795bd71c9
|
@ -12,6 +12,9 @@ local default_config = {
|
|||
-- When true, <Esc> will close the modal
|
||||
insert_only = true,
|
||||
|
||||
-- When true, input will start in insert mode.
|
||||
start_in_insert = true,
|
||||
|
||||
-- These are passed to nvim_open_win
|
||||
anchor = "SW",
|
||||
border = "rounded",
|
||||
|
|
|
@ -333,7 +333,9 @@ setmetatable(M, {
|
|||
aug END
|
||||
]])
|
||||
|
||||
vim.cmd("startinsert!")
|
||||
if config.start_in_insert then
|
||||
vim.cmd("startinsert!")
|
||||
end
|
||||
close_completion_window()
|
||||
M.highlight()
|
||||
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("starts in normal mode when start_in_insert = false", function()
|
||||
local orig_cmd = vim.cmd
|
||||
local startinsert_called = false
|
||||
vim.cmd = function(cmd)
|
||||
if cmd == "startinsert!" then
|
||||
startinsert_called = true
|
||||
end
|
||||
orig_cmd(cmd)
|
||||
end
|
||||
|
||||
require("dressing.config").input.start_in_insert = false
|
||||
run_input({
|
||||
"my text",
|
||||
"<CR>",
|
||||
}, {
|
||||
after_fn = function()
|
||||
vim.cmd = orig_cmd
|
||||
end,
|
||||
})
|
||||
assert(not startinsert_called, "Got 'true' expected 'false'")
|
||||
end)
|
||||
|
||||
a.it("cancels first callback if second input is opened", function()
|
||||
local tx, rx = channel.oneshot()
|
||||
vim.ui.input({}, tx)
|
||||
|
|
Loading…
Reference in New Issue