fix: Items take full width for bubblezone to work everywhere

Signed-off-by: Hadi <[email protected]>
This commit is contained in:
Hadi
2026-08-27 13:31:09 +02:00
parent f9d3e09ca3
commit 625f494623
+14 -4
View File
@@ -27,6 +27,16 @@ func clampToWidth(s string, width int) string {
return ansi.Truncate(s, width, "…")
}
func padToWidth(s string, width int) string {
if width <= 0 {
return s
}
if w := ansi.StringWidth(s); w < width {
s += strings.Repeat(" ", width-w)
}
return s
}
type entryDelegate struct{}
func (d entryDelegate) Height() int { return cardHeight }
@@ -76,10 +86,10 @@ func (d entryDelegate) Render(w io.Writer, m list.Model, index int, item list.It
}
lines := []string{
clampToWidth(side.Render(line1), width),
clampToWidth(side.Render(line2), width),
clampToWidth(side.Render(line3), width),
clampToWidth(side.Render(line4), width),
padToWidth(clampToWidth(side.Render(line1), width), width),
padToWidth(clampToWidth(side.Render(line2), width), width),
padToWidth(clampToWidth(side.Render(line3), width), width),
padToWidth(clampToWidth(side.Render(line4), width), width),
}
fmt.Fprint(w, zone.Mark(entryZoneID(index), strings.Join(lines, "\n")))
}