Skip to content

Commit

Permalink
Use strings.Builder to construct suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Oct 5, 2023
1 parent 3c47a5a commit 4585aea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,14 @@ func (c *Command) findSuggestions(arg string) string {
if c.SuggestionsMinimumDistance <= 0 {
c.SuggestionsMinimumDistance = 2
}
suggestionsString := ""
var sb strings.Builder
if suggestions := c.SuggestionsFor(arg); len(suggestions) > 0 {
suggestionsString += "\n\nDid you mean this?\n"
sb.WriteString("\n\nDid you mean this?\n")
for _, s := range suggestions {
suggestionsString += fmt.Sprintf("\t%v\n", s)
_, _ = fmt.Fprintf(&sb, "\t%v\n", s)
}
}
return suggestionsString
return sb.String()
}

func (c *Command) findNext(next string) *Command {
Expand Down

0 comments on commit 4585aea

Please sign in to comment.