diff --git a/src/util/string.h b/src/util/string.h index 72d3c6075b..4ad771f4ce 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -426,12 +426,19 @@ inline std::string wrap_rows(const std::string &from, { std::string to; + bool need_to_wrap = false; + size_t character_idx = 0; for (size_t i = 0; i < from.size(); i++) { if (character_idx > 0 && character_idx % row_len == 0) - to += '\n'; - if (!IS_UTF8_MULTB_INNER(from[i])) + need_to_wrap = true; + if (!IS_UTF8_MULTB_INNER(from[i])) { + if (need_to_wrap) { + to += '\n'; + need_to_wrap = false; + } character_idx++; + } to += from[i]; }