feat(ui): added options to sort/filter profiling data

This commit is contained in:
Folke Lemaitre 2022-12-23 10:43:22 +01:00
parent fde5feea6d
commit 7dfb9c1f5c
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 75 additions and 5 deletions

View file

@ -5,6 +5,13 @@ local Config = require("lazy.core.config")
---@class LazyViewState
---@field mode string
---@field plugin? string
local default_state = {
mode = "home",
profile = {
threshold = 0,
sort_time_taken = true,
},
}
---@class LazyView
---@field buf number
@ -69,7 +76,7 @@ function M.create(opts)
opts = opts or {}
local self = setmetatable({}, { __index = M })
self.state = { mode = "home" }
self.state = vim.deepcopy(default_state)
self:mount()
@ -96,6 +103,33 @@ function M.create(opts)
end
end)
self:on_key("<C-s>", function()
if self.state.mode == "profile" then
self.state.profile.sort_time_taken = not self.state.profile.sort_time_taken
self:update()
end
end)
self:on_key("<C-f>", function()
if self.state.mode == "profile" then
vim.ui.input({
prompt = "Enter time threshold in ms, like 0.5",
default = tostring(self.state.profile.threshold),
}, function(input)
if not input then
return
end
local num = input == "" and 0 or tonumber(input)
if not num then
Util.error("Please input a number")
else
self.state.profile.threshold = num
self:update()
end
end)
end
end)
self:setup_hover()
self:setup_modes()
return self