1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

View File

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