diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-04-27 13:55:32 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-04-27 13:55:32 +0100 |
| commit | 61c155fc40fff17de182b54a65a383c7b5128b74 (patch) | |
| tree | a4976c188275e5074e188adc7509e0b0b8bf8c32 /src/string.cc | |
| parent | d3bcf8c21e02e2e3bea3e9a77ffa72f84877f24a (diff) | |
Fix wrap_lines
Diffstat (limited to 'src/string.cc')
| -rw-r--r-- | src/string.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/string.cc b/src/string.cc index a2f1ff52..42f3d7ce 100644 --- a/src/string.cc +++ b/src/string.cc @@ -396,7 +396,7 @@ Vector<StringView> wrap_lines(StringView text, CharCount max_width) while (word_end != end and categorize(*word_end) == cat) ++word_end; - while (word_end - line_begin >= max_width) + while (word_end > line_begin and word_end - line_begin >= max_width) { auto line_end = last_word_end <= line_begin ? line_begin + max_width : last_word_end; @@ -519,6 +519,12 @@ UnitTest test_string{[]() kak_assert(wrapped[4] == "much_too_long_wo"); kak_assert(wrapped[5] == "rds"); + Vector<StringView> wrapped2 = wrap_lines("error: unknown type", 7); + kak_assert(wrapped2.size() == 3); + kak_assert(wrapped2[0] == "error:"); + kak_assert(wrapped2[1] == "unknown"); + kak_assert(wrapped2[2] == "type"); + kak_assert(escape("youpi:matin:tchou:", ':', '\\') == "youpi\\:matin\\:tchou\\:"); kak_assert(unescape("youpi\\:matin\\:tchou\\:", ':', '\\') == "youpi:matin:tchou:"); |
