Skip to content

Commit

Permalink
perf(ui_attach): router now only queues messages in vim.ui_attach. …
Browse files Browse the repository at this point in the history
…Use `SafeState` to execute queue when needed.
  • Loading branch information
folke committed May 16, 2024
1 parent 61947de commit 4c26991
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lua/noice/message/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function M.enable()
M._updater = Util.interval(Config.options.throttle, Util.protect(M.update))
end
M._updater()
vim.api.nvim_create_autocmd("SafeState", {
group = vim.api.nvim_create_augroup("NoiceRouter", { clear = true }),
callback = M.update,
})
end

function M.disable()
Expand All @@ -42,6 +46,7 @@ function M.disable()
Manager.clear()
M.update()
end
vim.api.nvim_create_augroup("NoiceRouter", { clear = true })
end

---@param route NoiceRouteConfig
Expand Down
6 changes: 2 additions & 4 deletions lua/noice/ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local Config = require("noice.config")
local Util = require("noice.util")
local Router = require("noice.message.router")
local Manager = require("noice.message.manager")
local Hacks = require("noice.util.hacks")

---@alias NoiceEvent MsgEvent|CmdlineEvent|NotifyEvent|LspEvent
---@alias NoiceKind MsgKind|NotifyLevel|LspKind
Expand Down Expand Up @@ -97,9 +96,8 @@ function M.enable()

-- check if we need to update the ui
if Manager.tick() > tick then
-- Util.debug(vim.inspect({ event, stack_level, Util.is_blocking(), tick, kind, ... }))
if Util.is_blocking() and event ~= "msg_ruler" and kind ~= "search_count" then
Util.try(Router.update)
do
-- Util.debug(vim.inspect({ event, stack_level, Util.is_blocking(), tick, kind, ... }))
end
else
local widget = M.parse_event(event)
Expand Down

0 comments on commit 4c26991

Please sign in to comment.