perf(dashboard): properly cleanup autocmds

This commit is contained in:
Folke Lemaitre 2024-11-30 21:45:41 +01:00
parent 3c1849a09b
commit 8e6d977ec9
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -962,8 +962,8 @@ function M.sections.terminal(opts)
pcall(vim.fn.jobstop, jid) pcall(vim.fn.jobstop, jid)
return true return true
end) end)
self.on("UpdatePre", close) self.on("UpdatePre", close, self.augroup)
self.on("Closed", close) self.on("Closed", close, self.augroup)
self:trace() self:trace()
end, end,
text = ("\n"):rep(height - 1), text = ("\n"):rep(height - 1),
@ -1049,13 +1049,14 @@ function M.setup()
local options = { showtabline = vim.o.showtabline, laststatus = vim.o.laststatus } local options = { showtabline = vim.o.showtabline, laststatus = vim.o.laststatus }
vim.o.showtabline, vim.o.laststatus = 0, 0 vim.o.showtabline, vim.o.laststatus = 0, 0
M.open({ buf = buf, win = wins[1] }).on("Closed", function() local dashboard = M.open({ buf = buf, win = wins[1] })
D.on("Closed", function()
for k, v in pairs(options) do for k, v in pairs(options) do
if vim.o[k] == 0 and v ~= 0 then if vim.o[k] == 0 and v ~= 0 then
vim.o[k] = v vim.o[k] = v
end end
end end
end) end, dashboard.augroup)
if Snacks.config.dashboard.debug then if Snacks.config.dashboard.debug then
Snacks.debug.stats({ min = 0.2 }) Snacks.debug.stats({ min = 0.2 })