From 322978c734866996274467de084a95e4f9b5e0b1 Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Tue, 4 Jun 2024 12:19:50 +0600 Subject: [PATCH] fix(input): mounting multiple inputs together --- lua/nui/input/init.lua | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lua/nui/input/init.lua b/lua/nui/input/init.lua index 712be70..0a974ea 100644 --- a/lua/nui/input/init.lua +++ b/lua/nui/input/init.lua @@ -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 @@ -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