Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display desciption if exists
Browse files Browse the repository at this point in the history
wd60622 committed Dec 30, 2024
1 parent cadb132 commit f995b72
Showing 3 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions lua/octo/gh/graphql.lua
Original file line number Diff line number Diff line change
@@ -3555,6 +3555,7 @@ query($name: String!, $owner: String!, $n_milestones: Int!) {
nodes {
id
title
description
}
}
}
26 changes: 17 additions & 9 deletions lua/octo/pickers/telescope/entry_maker.lua
Original file line number Diff line number Diff line change
@@ -340,23 +340,31 @@ function M.gen_from_project_card()
end
end

function M.gen_from_milestone()
function M.gen_from_milestone(title_width, show_description)
title_width = title_width or 10

local make_display = function(entry)
if not entry then
return nil
end

local columns = {
{ entry.milestone.title, "OctoDetailsLabel" },
}
local columns, items
if show_description then
columns = {
{ entry.milestone.title, "OctoDetailsLabel" },
{ entry.milestone.description },
}
items = { { width = title_width }, { remaining = true } }
else
columns = {
{ entry.milestone.title, "OctoDetailsLabel" },
}
items = { { width = title_width } }
end

local displayer = entry_display.create {
separator = "",
items = {
-- { width = 1 },
{ remaining = true },
-- { width = 1 },
},
items = items,
}

return displayer(columns)
15 changes: 14 additions & 1 deletion lua/octo/pickers/telescope/provider.lua
Original file line number Diff line number Diff line change
@@ -1298,11 +1298,24 @@ function M.milestones(opts)
return
end

local title_width = 0
for _, milestone in ipairs(nodes) do
title_width = math.max(title_width, #milestone.title)
end

local non_empty_descriptions = false
for _, milestone in ipairs(nodes) do
if not utils.is_blank(milestone.description) then
non_empty_descriptions = true
break
end
end

pickers
.new(vim.deepcopy(dropdown_opts), {
finder = finders.new_table {
results = nodes,
entry_maker = entry_maker.gen_from_milestone(),
entry_maker = entry_maker.gen_from_milestone(title_width, non_empty_descriptions),
},
sorter = conf.generic_sorter(opts),
attach_mappings = function(_, map)

0 comments on commit f995b72

Please sign in to comment.