diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-12-12 13:45:14 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-12-12 13:45:14 +0000 |
| commit | 563f62b467f339673ed4f61d8c3ee119c769a6eb (patch) | |
| tree | e0db1698ce650b36890c77dd9f280424ef66232a /src/buffer.cc | |
| parent | bd80cf0404b89b531312ac86e7868f8fd18052d5 (diff) | |
Fix Buffer::char_next when the line ends with an invalid utf8 sequence
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index 3f6fdadd..afc78976 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -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(); |
