Skip to content

Commit

Permalink
fix(input): mounting multiple inputs together
Browse files Browse the repository at this point in the history
  • Loading branch information
MunifTanjim committed Jun 4, 2024
1 parent a3597dc commit 9ff6411
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lua/nui/input/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,6 @@ function Input:mount()
})
end

if #self._.default_value then
self:on(event.InsertEnter, function()
vim.api.nvim_feedkeys(self._.default_value, "n", true)
end, { once = true })
end

vim.fn.prompt_setprompt(self.bufnr, self._.prompt:content())
if self._.prompt:length() > 0 then
vim.schedule(function()
self._.prompt:highlight(self.bufnr, self.ns_id, 1, 0)
end)
end

---@deprecated
props.on_submit = function(value)
self._.pending_submit_value = value
Expand All @@ -122,6 +109,20 @@ function Input:mount()

vim.fn.prompt_setinterrupt(self.bufnr, props.on_close)

vim.fn.prompt_setprompt(self.bufnr, self._.prompt:content())

self:on(event.InsertEnter, function()
if #self._.default_value then
vim.api.nvim_feedkeys(self._.default_value, "n", true)
end

if self._.prompt:length() > 0 then
vim.schedule(function()
self._.prompt:highlight(self.bufnr, self.ns_id, 1, 0)
end)
end
end, { once = true })

vim.api.nvim_command("startinsert!")
end

Expand Down

0 comments on commit 9ff6411

Please sign in to comment.