feat(dashboard): when a section has a title, use that for action and key. If not put it in the section. Fixes #189

This commit is contained in:
Folke Lemaitre 2024-12-02 16:33:00 +01:00
parent 6e3b9546de
commit 045a17da06
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -482,7 +482,18 @@ function D:resolve(item, results, parent)
-- add the title if there are child items
if #results >= first_child and item.title then
table.insert(results, first_child, { title = item.title, icon = item.icon, pane = item.pane })
table.insert(results, first_child, {
title = item.title,
icon = item.icon,
pane = item.pane,
action = item.action,
key = item.key,
label = item.label,
})
item.action = nil
item.label = nil
item.key = nil
first_child = first_child + 1
end
if item.gap then -- add padding between child items
@ -992,8 +1003,9 @@ function M.sections.terminal(opts)
end
end
return {
action = opts.action,
key = opts.key,
action = not opts.title and opts.action or nil,
key = not opts.title and opts.key or nil,
label = not opts.title and opts.label or nil,
render = function(_, pos)
self:trace("terminal.render")
local win = vim.api.nvim_open_win(buf, false, {