@@ -1,6 +1,7 @@
11package dialog
22
33import (
4+ "fmt"
45 "strings"
56 "time"
67
@@ -71,35 +72,23 @@ func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, w
7172 style = t.Dialog.SelectedItem
7273 }
7374
74− width -= style.GetHorizontalFrameSize()
75−
7675 var age string
76+ var ageLen int
77+ lineWidth := width
7778 if updatedAt > 0 {
78− age = humanize.Time(time.Unix(updatedAt, 0))
79+ age = fmt.Sprintf(" %s ", humanize.Time(time.Unix(updatedAt, 0)))
7980 if focused {
8081 age = t.Base.Render(age)
8182 } else {
8283 age = t.Subtle.Render(age)
8384 }
8485
85− age = " " + age
86− }
87−
88− var ageLen int
89− var right string
90− lineWidth := width
91− if updatedAt > 0 {
9286 ageLen = lipgloss.Width(age)
93− lineWidth -= ageLen
9487 }
9588
96− title = ansi.Truncate(title, max(0, lineWidth), "…")
89+ title = ansi.Truncate(title, max(0, lineWidth), "")
9790 titleLen := lipgloss.Width(title)
98−
99− if updatedAt > 0 {
100− right = lipgloss.NewStyle().AlignHorizontal(lipgloss.Right).Width(width - titleLen).Render(age)
101− }
102−
91+ gap := strings.Repeat(" ", max(0, lineWidth-titleLen-ageLen))
10392 content := title
10493 if matches := len(m.MatchedIndexes); matches > 0 {
10594 var lastPos int
@@ -129,7 +118,7 @@ func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, w
129118 content = strings.Join(parts, "")
130119 }
131120
132− content = style.Render(content + right)
121+ content = style.Render(content + gap + age)
133122 cache[width] = content
134123 return content
135124}