diff --git a/lua/noice/message/init.lua b/lua/noice/message/init.lua index d1df80f9..1bb9746a 100644 --- a/lua/noice/message/init.lua +++ b/lua/noice/message/init.lua @@ -65,7 +65,7 @@ function Message:focus() if win then vim.api.nvim_set_current_win(win) -- switch to normal mode - vim.cmd("stopinsert") + vim.cmd("stopinsert") return true end end diff --git a/lua/noice/text/block.lua b/lua/noice/text/block.lua index f5a2a74e..a9dea35e 100644 --- a/lua/noice/text/block.lua +++ b/lua/noice/text/block.lua @@ -1,7 +1,6 @@ local require = require("noice.util.lazy") local Highlight = require("noice.text.highlight") -local Util = require("noice.util") local NuiLine = require("nui.line") local Object = require("nui.object") @@ -10,6 +9,7 @@ local Object = require("nui.object") ---@class NoiceBlock ---@field _lines NuiLine[] +---@field fix_cr boolean? ---@overload fun(content?: NoiceContent|NoiceContent[], highlight?: string|table): NoiceBlock local Block = Object("Block") @@ -110,7 +110,7 @@ function Block:_append(content, highlight) if #self._lines == 0 then table.insert(self._lines, NuiLine()) end - if type(content) == "string" and true then + if type(content) == "string" and self.fix_cr ~= false then -- handle carriage returns. They overwrite the line from the first character local cr = content:match("^.*()[\r]") if cr then @@ -167,8 +167,10 @@ function Block:append(contents, highlight) ---@type number|string|table, string local attr_id, text = unpack(content) -- msg_show messages can contain invalid \r characters - text = text:gsub("%^M", "\r") - text = text:gsub("\r\n", "\n") + if self.fix_cr ~= false then + text = text:gsub("%^M", "\r") + text = text:gsub("\r\n", "\n") + end ---@type string|table|nil local hl_group diff --git a/lua/noice/ui/cmdline.lua b/lua/noice/ui/cmdline.lua index 5c5d6715..f55de1e7 100644 --- a/lua/noice/ui/cmdline.lua +++ b/lua/noice/ui/cmdline.lua @@ -111,6 +111,7 @@ end ---@param text_only? boolean function Cmdline:format(message, text_only) local format = self:get_format() + message.fix_cr = false if format.icon then message:append(NoiceText.virtual_text(format.icon, format.icon_hl_group))