Skip to content

Commit

Permalink
fix(calendar): overlapping month names in the calendar view
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed May 14, 2023
1 parent c318267 commit 709cf78
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lua/neorg/modules/core/ui/calendar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.private = {
}
)

module.private.extmarks.decorational.month_headings[month_name] = module.private.set_decorational_extmark(
module.private.extmarks.decorational.month_headings[weekday_banner_extmark_id] = module.private.set_decorational_extmark(
ui_info,
4,
weekday_banner_id[2]
Expand All @@ -111,7 +111,7 @@ module.private = {
{ { month_name, "@text.underline" } },
nil,
{
id = module.private.extmarks.decorational.month_headings[month_name],
id = module.private.extmarks.decorational.month_headings[weekday_banner_extmark_id],
}
)
end,
Expand All @@ -120,8 +120,6 @@ module.private = {
offset = offset or 0
distance = distance or 4

module.private.extmarks.decorational.weekday_displays = {}

-- Render the days of the week
-- To effectively do this, we grab all the weekdays from a constant time.
-- This makes the weekdays retrieved locale dependent (which is what we want).
Expand All @@ -148,17 +146,22 @@ module.private = {
weekdays_string_length = weekdays_string_length + (i ~= 7 and 4 or 2)
end

local absolute_offset = offset + (offset < 0 and (-offset * 100) or 0)

local weekday_banner_id = module.private.set_decorational_extmark(
ui_info,
6,
(weekdays_string_length * offset)
+ (offset < 0 and -distance or (offset > 0 and distance or 0)) * math.abs(offset),
weekdays_string_length,
weekdays,
"center"
"center",
{
id = module.private.extmarks.decorational.weekday_displays[absolute_offset],
}
)

table.insert(module.private.extmarks.decorational.weekday_displays, weekday_banner_id)
module.private.extmarks.decorational.weekday_displays[absolute_offset] = weekday_banner_id

return weekday_banner_id
end,
Expand Down

0 comments on commit 709cf78

Please sign in to comment.