Skip to content

Commit 4bc87c4

Browse files
yepzdkclaude
andcommitted
Fix column alignment with ANSI color codes
- formatProject now pads to exact visual width, accounting for ANSI codes - ANSI escape sequences don't count toward visual width - Columns now align properly with headers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b86ecd3 commit 4bc87c4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/ui/ui.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func RenderList(sessions []session.Session) {
5353
desc = s.Task
5454
}
5555

56-
fmt.Printf("%s%s %-13s%s %-35s %-15s %s\n",
56+
fmt.Printf("%s%s %-13s%s %s %-15s %s\n",
5757
color, symbol, s.Status, Reset,
5858
formatProject(s, 35),
5959
elapsed,
@@ -116,7 +116,7 @@ func RenderLive(sessions []session.Session) {
116116
desc = s.Task
117117
}
118118

119-
fmt.Printf("%s%s %-13s%s %-35s %-15s %s\r\n",
119+
fmt.Printf("%s%s %-13s%s %s %-15s %s\r\n",
120120
color, symbol, s.Status, Reset,
121121
formatProject(s, 35),
122122
elapsed,
@@ -240,7 +240,7 @@ func truncate(s string, max int) string {
240240
return s[:max-3] + "..."
241241
}
242242

243-
// formatProject formats the project name with optional indicators
243+
// formatProject formats the project name with optional indicators, padded to maxLen visible chars
244244
func formatProject(s session.Session, maxLen int) string {
245245
name := s.Project
246246
var suffixes []string
@@ -276,11 +276,19 @@ func formatProject(s session.Session, maxLen int) string {
276276

277277
// Truncate name to fit with suffixes
278278
truncated := truncate(name, maxLen-suffixLen-len(suffixes)) // -len for spaces
279+
visibleLen := len(truncated)
279280

280281
// Build result
281282
result := truncated
282283
for _, suffix := range suffixes {
283284
result += " " + suffix
285+
visibleLen++ // space before suffix
286+
}
287+
visibleLen += suffixLen
288+
289+
// Pad to maxLen with spaces (ANSI codes don't count for visual width)
290+
if visibleLen < maxLen {
291+
result += strings.Repeat(" ", maxLen-visibleLen)
284292
}
285293

286294
return result

0 commit comments

Comments
 (0)