wrap: Simplify loop logic

Suggested by @julian7
This commit is contained in:
Anatoli Babenia 2022-10-04 10:30:31 +03:00 committed by GitHub
parent 59d580978e
commit 1d2696072f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
help.go
View File

@ -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))