diff --git a/lua/noice/ui/cmdline.lua b/lua/noice/ui/cmdline.lua index f55de1e7..4b384eee 100644 --- a/lua/noice/ui/cmdline.lua +++ b/lua/noice/ui/cmdline.lua @@ -156,6 +156,7 @@ end ---@type NoiceCmdline[] M.cmdlines = {} +M.skipped = false function M.on_show(event, content, pos, firstc, prompt, indent, level) local c = Cmdline({ @@ -167,6 +168,14 @@ function M.on_show(event, content, pos, firstc, prompt, indent, level) indent = indent, level = level, }) + + -- This was triggered by a force redraw, so skip it + if c:get():find(Hacks.SPECIAL, 1, true) then + M.skipped = true + return + end + M.skipped = false + local last = M.cmdlines[level] and M.cmdlines[level].state if not vim.deep_equal(c.state, last) then M.active = c @@ -189,7 +198,11 @@ function M.on_hide(_, level) end function M.on_pos(_, pos, level) - if M.cmdlines[level] and M.cmdlines[level].state.pos ~= pos then + if M.skipped then + return + end + local c = M.cmdlines[level] + if c and c.state.pos ~= pos then M.cmdlines[level].state.pos = pos M.update() end diff --git a/lua/noice/util/hacks.lua b/lua/noice/util/hacks.lua index 00a83d42..813fb2ab 100644 --- a/lua/noice/util/hacks.lua +++ b/lua/noice/util/hacks.lua @@ -241,15 +241,14 @@ function M.fix_cmp() end) end +M.SPECIAL = "Þ" function M.cmdline_force_redraw() if not require("noice.util.ffi").cmdpreview then return end - -- HACK: this will trigger redraw during substitute and cmdpreview, - -- but when moving the cursor, the screen will be cleared until - -- a new character is entered - vim.api.nvim_feedkeys(" " .. Util.BS, "n", true) + -- HACK: this will trigger redraw during substitute and cmdpreview + vim.api.nvim_feedkeys(M.SPECIAL .. Util.BS, "n", true) end ---@type string? diff --git a/lua/noice/util/init.lua b/lua/noice/util/init.lua index 60385ab6..615f61d0 100644 --- a/lua/noice/util/init.lua +++ b/lua/noice/util/init.lua @@ -18,6 +18,8 @@ M.ESC = M.t("") M.BS = M.t("") M.EXIT = M.t("") M.LUA_CALLBACK = "\x80\253g" +M.RIGHT = M.t("") +M.LEFT = M.t("") M.CMD = "\x80\253h" ---@generic F: fun() @@ -325,6 +327,9 @@ function M.debug(data) if not fd then error(("Could not open file %s for writing"):format(file)) end + if type(data) ~= "string" then + data = vim.inspect(data) + end fd:write(data .. "\n") fd:close() end