Fix some remaining uses of invalid atom coordinates

This commit is contained in:
Maxime Coste 2017-06-16 08:06:24 +01:00
parent 4ed790632d
commit 2992d5bb0b

View File

@ -236,7 +236,8 @@ ColumnCount find_display_column(const DisplayLine& line, const Buffer& buffer,
coord >= atom.begin() and coord < atom.end()) coord >= atom.begin() and coord < atom.end())
{ {
if (atom.type() == DisplayAtom::Range) if (atom.type() == DisplayAtom::Range)
column += column_length(buffer, atom.begin(), coord); column += utf8::column_distance(get_iterator(buffer, atom.begin()),
get_iterator(buffer, coord));
return column; return column;
} }
column += atom.length(); column += atom.length();
@ -255,8 +256,8 @@ BufferCoord find_buffer_coord(const DisplayLine& line, const Buffer& buffer,
{ {
if (atom.type() == DisplayAtom::Range) if (atom.type() == DisplayAtom::Range)
return buffer.clamp( return buffer.clamp(
utf8::advance(buffer.iterator_at(atom.begin()), utf8::advance(get_iterator(buffer, atom.begin()),
buffer.iterator_at(range.end), get_iterator(buffer, range.end),
std::max(0_col, column)).coord()); std::max(0_col, column)).coord());
return buffer.clamp(atom.begin()); return buffer.clamp(atom.begin());
} }