Buffer: change clamp logic to preserve ordering
clamp could change ordering between a coordinate past the end. Say in a buffer with 1 line of 2 char: {0, 1} was clamped to {0, 1} {1, 0} was clamped to {0, 0} That was reversing their ordering, and might be the root cause of the bug lurking in undo range computation.
This commit is contained in:
parent
80ce768994
commit
d45f16b6c8
|
@ -172,7 +172,9 @@ BufferIterator Buffer::iterator_at(BufferCoord coord) const
|
|||
|
||||
BufferCoord Buffer::clamp(BufferCoord coord) const
|
||||
{
|
||||
coord.line = Kakoune::clamp(coord.line, 0_line, line_count() - 1);
|
||||
if (coord > back_coord())
|
||||
coord = back_coord();
|
||||
kak_assert(coord.line >= 0 and coord.line < line_count());
|
||||
ByteCount max_col = std::max(0_byte, m_lines[coord.line].length() - 1);
|
||||
coord.column = Kakoune::clamp(coord.column, 0_byte, max_col);
|
||||
return coord;
|
||||
|
|
Loading…
Reference in New Issue
Block a user