From 616b886a63060d80b3c463744769bdfc0f30504c Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 22 Apr 2020 22:30:09 -0700 Subject: OBOE --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 4c66133..9d96dfe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,16 +101,18 @@ fn wrap(text: Vec, width: u16) -> Vec { let mut word = 0; for (i, c) in chunk.char_indices() { - line += 1; - word += 1; if c == ' ' { space = i; word = 0; + } else { + word += 1; } if line == width { wrapped.push(String::from(&chunk[start..space])); start = space + 1; line = word; + } else { + line += 1; } } wrapped.push(String::from(&chunk[start..])); -- cgit v1.2.3