Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(summary): ordering and indentation of nested entries #1486

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions lua/neorg/modules/core/summary/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,18 @@ module.load = function()
local starting_prefix = string.rep("*", heading_level)

local function add_category(category, data, level)
local result_temp = {}
local sub_cats_temp = {}
local new_prefix = starting_prefix .. string.rep("*", level)
table.insert(result, new_prefix .. " " .. category)
table.insert(result_temp, new_prefix .. " " .. category)
for _, datapoint in ipairs(data) do
if datapoint.sub_categories then
level = level + 1
for sub_category, sub_data in vim.spairs(datapoint.sub_categories) do
add_category(sub_category, sub_data, level)
table.insert(sub_cats_temp, add_category(sub_category, sub_data, level + 1))
end
else
table.insert(
result,
result_temp,
table.concat({
string.rep(" ", level + 1),
" - {:$",
Expand All @@ -212,9 +213,18 @@ module.load = function()
)
end
end
for _, sub_cat in pairs(sub_cats_temp) do
for _, row in pairs(sub_cat) do
table.insert(result_temp, row)
end
end
return result_temp
end
for category, data in vim.spairs(categories) do
add_category(category, data, 0)
local temp = add_category(category, data, 0)
for _, row in pairs(temp) do
table.insert(result, row)
end
end
return result
end
Expand Down
Loading