mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-06 11:48:23 +00:00
feat(picker.debug): debug option to detect garbage collection leaks
This commit is contained in:
parent
52c5ba857c
commit
b59f4ff477
2 changed files with 10 additions and 0 deletions
|
@ -322,6 +322,7 @@ local defaults = {
|
||||||
---@class snacks.picker.debug
|
---@class snacks.picker.debug
|
||||||
debug = {
|
debug = {
|
||||||
scores = false, -- show scores in the list
|
scores = false, -- show scores in the list
|
||||||
|
leaks = false, -- show when pickers don't get garbage collected
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,15 @@ function M.new(opts)
|
||||||
if self.opts.source == "resume" then
|
if self.opts.source == "resume" then
|
||||||
return M.resume()
|
return M.resume()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.opts.debug.leaks then
|
||||||
|
collectgarbage("collect")
|
||||||
|
local picker_count = vim.tbl_count(M._pickers)
|
||||||
|
if picker_count > 0 then
|
||||||
|
Snacks.notify.error("` " .. picker_count .. " ` active pickers.", { title = "Snacks Picker" })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.visual = Snacks.picker.util.visual()
|
self.visual = Snacks.picker.util.visual()
|
||||||
self.start_time = uv.hrtime()
|
self.start_time = uv.hrtime()
|
||||||
Snacks.picker.current = self
|
Snacks.picker.current = self
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue