wrap: Simplify loop logic
Suggested by @julian7
This commit is contained in:
parent
59d580978e
commit
1d2696072f
10
help.go
10
help.go
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user