Treat non printable characters as zero-width instead of -1 width

This fix a bug when opening a file where a line has a lot of unprintable
chars (like a binary file) which was confusing Kakoune into considering
that the line length in column was negative.
This commit is contained in:
Maxime Coste 2017-07-07 10:57:32 +09:00
parent 620e718087
commit 6604aa66f7

View File

@ -55,7 +55,10 @@ inline bool is_basic_alpha(Codepoint c) noexcept
inline ColumnCount codepoint_width(Codepoint c) noexcept
{
return c == '\n' ? 1 : wcwidth((wchar_t)c);
if (c == '\n')
return 1;
const auto width = wcwidth((wchar_t)c);
return width > 0 ? width : 0;
}
enum class CharCategories