Skip to content

Commit 89c42c4

Browse files
authored
Merge pull request #1995 from Adirio/fix-sort
🐛 Fix sorting issue with plugin versions and their supported project versions
2 parents 3c8e370 + f1685b8 commit 89c42c4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/cli/root.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (c cli) getPluginTable() string {
8989
maxPluginKeyLength = len(pluginKeysHeader)
9090
pluginKeys = make([]string, 0, len(c.plugins))
9191
maxProjectVersionLength = len(projectVersionsHeader)
92-
projectVersions = make([]string, 0, len(c.plugins))
92+
projectVersions = make(map[string]string, len(c.plugins))
9393
)
9494

9595
for pluginKey, plugin := range c.plugins {
@@ -106,7 +106,7 @@ func (c cli) getPluginTable() string {
106106
if len(supportedProjectVersionsStr) > maxProjectVersionLength {
107107
maxProjectVersionLength = len(supportedProjectVersionsStr)
108108
}
109-
projectVersions = append(projectVersions, supportedProjectVersionsStr)
109+
projectVersions[pluginKey] = supportedProjectVersionsStr
110110
}
111111

112112
lines := make([]string, 0, len(c.plugins)+2)
@@ -116,8 +116,8 @@ func (c cli) getPluginTable() string {
116116
strings.Repeat("-", maxProjectVersionLength+2))
117117

118118
sort.Strings(pluginKeys)
119-
for i, pluginKey := range pluginKeys {
120-
supportedProjectVersions := projectVersions[i]
119+
for _, pluginKey := range pluginKeys {
120+
supportedProjectVersions := projectVersions[pluginKey]
121121
lines = append(lines, fmt.Sprintf(" %[1]*[2]s | %[3]*[4]s",
122122
maxPluginKeyLength, pluginKey, maxProjectVersionLength, supportedProjectVersions))
123123
}

0 commit comments

Comments
 (0)