Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: verbose analyse output improperly trimmed #3785

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2321,11 +2321,11 @@ func analyzeMetafileImpl(metafile string, opts AnalyzeMetafileOptions) string {
third := "100.0%"

table = append(table, tableEntry{
first: fmt.Sprintf("%s%s%s", colors.Bold, entry.name, colors.Reset),
first: entry.name,
firstLen: utf8.RuneCountInString(entry.name),
second: fmt.Sprintf("%s%s%s", colors.Bold, second, colors.Reset),
second: second,
secondLen: len(second),
third: fmt.Sprintf("%s%s%s", colors.Bold, third, colors.Reset),
third: third,
thirdLen: len(third),
isTopLevel: true,
})
Expand Down Expand Up @@ -2402,8 +2402,10 @@ func analyzeMetafileImpl(metafile string, opts AnalyzeMetafileOptions) string {
// Render the columns now that we know the widths
for _, entry := range table {
prefix := "\n"
color := colors.Bold
if !entry.isTopLevel {
prefix = ""
color = ""
}

// Import paths don't have second and third columns
Expand All @@ -2425,17 +2427,23 @@ func analyzeMetafileImpl(metafile string, opts AnalyzeMetafileOptions) string {
extraSpace = 1
}

sb.WriteString(fmt.Sprintf("%s %s %s%s%s %s %s%s%s %s\n",
sb.WriteString(fmt.Sprintf("%s %s%s%s %s%s%s %s%s%s %s%s%s %s%s%s\n",
prefix,
color,
entry.first,
colors.Reset,
colors.Dim,
strings.Repeat(lineChar, extraSpace+maxFirstLen-entry.firstLen+maxSecondLen-entry.secondLen),
colors.Reset,
color,
secondTrimmed,
colors.Reset,
colors.Dim,
strings.Repeat(lineChar, extraSpace+maxThirdLen-entry.thirdLen+len(second)-len(secondTrimmed)),
colors.Reset,
color,
entry.third,
colors.Reset,
))
}

Expand Down