Skip to content

Commit

Permalink
wrap: Simplify loop logic
Browse files Browse the repository at this point in the history
Suggested by @julian7
  • Loading branch information
abitrolly committed Oct 4, 2022
1 parent 59d5809 commit 1d26960
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions help.go
Expand Up @@ -475,10 +475,14 @@ func wrap(input string, offset int, wrapAt int) string {
padding := strings.Repeat(" ", offset)

for i, line := range lines {
if line == "" {
sb.WriteString("\n")
continue
}

// the first line is not indented
if i != 0 {
if len(line) > 0 {
sb.WriteString(padding)
}
sb.WriteString(padding)
}

sb.WriteString(wrapLine(line, offset, wrapAt, padding))
Expand Down

0 comments on commit 1d26960

Please sign in to comment.