Fix Buffer::char_next when the line ends with an invalid utf8 sequence

This commit is contained in:
Maxime Coste 2013-12-12 13:45:14 +00:00
parent bd80cf0404
commit 563f62b467

View File

@ -673,6 +673,12 @@ BufferCoord Buffer::char_next(BufferCoord coord) const
{
auto& line = m_lines[coord.line].content;
coord.column += utf8::codepoint_size(line.begin() + (int)coord.column);
// Handle invalid utf-8
if (coord.column >= line.length())
{
++coord.line;
coord.column = 0;
}
}
else if (coord.line == m_lines.size() - 1)
coord.column = m_lines.back().length();