cli: Fix off-by-one error in smart-wrap

pull/4627/head
Major Taylor 2020-04-27 17:10:36 -04:00 committed by GitHub
parent 682838a0cf
commit 9edbcb823c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -91,9 +91,9 @@ fn pretty_description(s string) string {
// Give us enough room, better a little bigger than smaller // Give us enough room, better a little bigger than smaller
mut acc := strings.new_builder(((s.len / chars_per_line) + 1) * (width + 1)) mut acc := strings.new_builder(((s.len / chars_per_line) + 1) * (width + 1))
mut i := chars_per_line - 1 mut i := chars_per_line - 2
mut j := 0 mut j := 0
for ; i < s.len ; i += chars_per_line - 1 { for ; i < s.len ; i += chars_per_line - 2 {
for s.str[i] != ` ` { i-- } for s.str[i] != ` ` { i-- }
// indent was already done the first iteration // indent was already done the first iteration
if j != 0 { acc.write(indent) } if j != 0 { acc.write(indent) }