Handle correctly cases where codepoint_width returns -1

Fixes #972
This commit is contained in:
Maxime Coste 2016-12-14 13:53:30 +00:00
parent 85cd27138d
commit 377046e315

View File

@ -114,7 +114,7 @@ public:
explicit String(Codepoint cp, ColumnCount count)
{
kak_assert(count % codepoint_width(cp) == 0);
int cp_count = (int)(count / codepoint_width(cp));
int cp_count = (int)(count / std::max(codepoint_width(cp), 1_col));
reserve(utf8::codepoint_size(cp) * cp_count);
while (cp_count-- > 0)
utf8::dump(std::back_inserter(*this), cp);