Skip to content

Commit

Permalink
fix(messages): include any messages before Noice was started as one h…
Browse files Browse the repository at this point in the history
…istory_show message. Fixes #799
  • Loading branch information
folke committed May 15, 2024
1 parent 72f72d3 commit 61947de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/noice/ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ function M.enable()
return
end

if options.ext_messages then
require("noice.ui.msg").setup()
end

local safe_handle = Util.protect(M.handle, { msg = "An error happened while handling a ui event" })
M._attached = true

Expand Down
10 changes: 10 additions & 0 deletions lua/noice/ui/msg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ M.last = nil
---@type NoiceMessage[]
M._messages = {}

function M.setup()
local hist = vim.trim(vim.api.nvim_cmd({ cmd = "messages" }, { output = true }))
if hist == "" then
return
end
local message = M.get(M.events.history_show)
message:set(hist)
Manager.add(message)
end

function M.is_error(kind)
return vim.tbl_contains({ M.kinds.echoerr, M.kinds.lua_error, M.kinds.rpc_error, M.kinds.emsg }, kind)
end
Expand Down

0 comments on commit 61947de

Please sign in to comment.