Skip to content

Commit 22aeea7

Browse files
committed
Fix review comments
1 parent 9bf6021 commit 22aeea7

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

internal/tui/calendar.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,11 @@ func (v *calendarView) fetchIdentity() tea.Cmd {
260260
if err != nil || identity == nil {
261261
return identityLoadedMsg{firstWeekDay: time.Monday}
262262
}
263-
return identityLoadedMsg{firstWeekDay: time.Weekday(identity.FirstWeekDay)}
263+
wd := identity.FirstWeekDay
264+
if wd < 0 || wd > 6 {
265+
wd = 1 // default to Monday
266+
}
267+
return identityLoadedMsg{firstWeekDay: time.Weekday(wd)}
264268
}
265269
}
266270

internal/tui/calendar_views.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,19 +804,28 @@ func truncateStr(s string, maxLen int) string {
804804
if maxLen <= 0 {
805805
return ""
806806
}
807-
if len(s) <= maxLen {
807+
if lipgloss.Width(s) <= maxLen {
808808
return s
809809
}
810810
if maxLen <= 1 {
811811
return "…"
812812
}
813-
return s[:maxLen-1] + "…"
813+
runes := []rune(s)
814+
for len(runes) > 0 && lipgloss.Width(string(runes))+lipgloss.Width("…") > maxLen {
815+
runes = runes[:len(runes)-1]
816+
}
817+
return string(runes) + "…"
814818
}
815819

816820
func centerPad(s string, width int) string {
817-
pad := width - len(s)
821+
sw := lipgloss.Width(s)
822+
pad := width - sw
818823
if pad <= 0 {
819-
return s[:width]
824+
runes := []rune(s)
825+
for len(runes) > 0 && lipgloss.Width(string(runes)) > width {
826+
runes = runes[:len(runes)-1]
827+
}
828+
return string(runes)
820829
}
821830
left := pad / 2
822831
right := pad - left

internal/tui/loading.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,39 @@ var hourglassFrames = [hourglassTotalFrames][]string{
9191
" │⣿⣿⣿│ ",
9292
" ╰───╯",
9393
},
94-
{ // 8: 90° horizontal — sand on right
94+
{ // 8: ~67° tilt
9595
"╭─ ",
9696
"│ ──╮ ",
9797
"╰─ ⣠╭── ",
9898
" ──╯ ⣾⣿⣿─╮",
9999
" ╰──⣿│",
100100
" ─╯",
101101
},
102-
{ // 8: 90° horizontal — sand on right
102+
{ // 9: 90° horizontal — sand on right
103103
" ",
104104
"╭───╮ ╭───╮",
105105
"│ ⣠⣾⣿⣿⣿│",
106106
"╰───╯ ╰───╯",
107107
" ",
108108
" ",
109109
},
110-
{ // 8: 90° horizontal — sand on right
110+
{ // 10: ~113° tilt
111111
" ─╮",
112112
" ╭──⣿│",
113113
" ──╮ ⣾⣿⣿─╯",
114114
"╭─ ╰── ",
115115
"│ ──╯ ",
116116
"╰─ ",
117117
},
118-
{ // 9: ~135° tilt — sand now top-right, empty bottom-left
118+
{ // 11: ~135° tilt — sand now top-right, empty bottom-left
119119
" ╭───╮",
120120
" │⣿⣿⣿│ ",
121121
" ╰╮ ╭╯ ",
122122
" ╭╯ ╰╮ ",
123123
" │ │ ",
124124
"╰───╯ ",
125125
},
126-
{ // 10: 180° inverted — sand at top, glass upside-down
126+
{ // 12: 180° inverted — sand at top, glass upside-down
127127
" ╭───╮ ",
128128
" │⣿⣿⣿│ ",
129129
" ╰╮⣿╭╯ ",

0 commit comments

Comments
 (0)