Skip to content

Commit 6679ec8

Browse files
authored
fix: verbose analyse output improperly trimmed (#3785)
Due to the `second` column value ending with `colors.Reset` for top-level entries, it was improperly trimmed, thus resulting in a larger space after it (and a smaler line in verbose mode).
1 parent 94f09ea commit 6679ec8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pkg/api/api_impl.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,11 +2350,11 @@ func analyzeMetafileImpl(metafile string, opts AnalyzeMetafileOptions) string {
23502350
third := "100.0%"
23512351

23522352
table = append(table, tableEntry{
2353-
first: fmt.Sprintf("%s%s%s", colors.Bold, entry.name, colors.Reset),
2353+
first: entry.name,
23542354
firstLen: utf8.RuneCountInString(entry.name),
2355-
second: fmt.Sprintf("%s%s%s", colors.Bold, second, colors.Reset),
2355+
second: second,
23562356
secondLen: len(second),
2357-
third: fmt.Sprintf("%s%s%s", colors.Bold, third, colors.Reset),
2357+
third: third,
23582358
thirdLen: len(third),
23592359
isTopLevel: true,
23602360
})
@@ -2431,8 +2431,10 @@ func analyzeMetafileImpl(metafile string, opts AnalyzeMetafileOptions) string {
24312431
// Render the columns now that we know the widths
24322432
for _, entry := range table {
24332433
prefix := "\n"
2434+
color := colors.Bold
24342435
if !entry.isTopLevel {
24352436
prefix = ""
2437+
color = ""
24362438
}
24372439

24382440
// Import paths don't have second and third columns
@@ -2454,17 +2456,23 @@ func analyzeMetafileImpl(metafile string, opts AnalyzeMetafileOptions) string {
24542456
extraSpace = 1
24552457
}
24562458

2457-
sb.WriteString(fmt.Sprintf("%s %s %s%s%s %s %s%s%s %s\n",
2459+
sb.WriteString(fmt.Sprintf("%s %s%s%s %s%s%s %s%s%s %s%s%s %s%s%s\n",
24582460
prefix,
2461+
color,
24592462
entry.first,
2463+
colors.Reset,
24602464
colors.Dim,
24612465
strings.Repeat(lineChar, extraSpace+maxFirstLen-entry.firstLen+maxSecondLen-entry.secondLen),
24622466
colors.Reset,
2467+
color,
24632468
secondTrimmed,
2469+
colors.Reset,
24642470
colors.Dim,
24652471
strings.Repeat(lineChar, extraSpace+maxThirdLen-entry.thirdLen+len(second)-len(secondTrimmed)),
24662472
colors.Reset,
2473+
color,
24672474
entry.third,
2475+
colors.Reset,
24682476
))
24692477
}
24702478

0 commit comments

Comments
 (0)