Allow l/h to cross line boundaries

l and h are now respectively "next character" and "previous character"
This commit is contained in:
Maxime Coste 2018-02-24 21:32:11 +11:00
parent 6a6e71dc0f
commit 2a60af25dc

View File

@ -194,9 +194,7 @@ BufferCoord Buffer::clamp(BufferCoord coord) const
BufferCoord Buffer::offset_coord(BufferCoord coord, CharCount offset, ColumnCount, bool) BufferCoord Buffer::offset_coord(BufferCoord coord, CharCount offset, ColumnCount, bool)
{ {
StringView line = m_lines[coord.line]; return utf8::advance(iterator_at(coord), offset < 0 ? begin() : end()-1, offset).coord();
auto target = utf8::advance(&line[coord.column], offset < 0 ? line.begin() : line.end()-1, offset);
return {coord.line, (int)(target - line.begin())};
} }
BufferCoordAndTarget Buffer::offset_coord(BufferCoordAndTarget coord, LineCount offset, ColumnCount tabstop, bool avoid_eol) BufferCoordAndTarget Buffer::offset_coord(BufferCoordAndTarget coord, LineCount offset, ColumnCount tabstop, bool avoid_eol)