Fix Buffer::char_next when the line ends with an invalid utf8 sequence
This commit is contained in:
parent
bd80cf0404
commit
563f62b467
|
@ -673,6 +673,12 @@ BufferCoord Buffer::char_next(BufferCoord coord) const
|
||||||
{
|
{
|
||||||
auto& line = m_lines[coord.line].content;
|
auto& line = m_lines[coord.line].content;
|
||||||
coord.column += utf8::codepoint_size(line.begin() + (int)coord.column);
|
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)
|
else if (coord.line == m_lines.size() - 1)
|
||||||
coord.column = m_lines.back().length();
|
coord.column = m_lines.back().length();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user