summaryrefslogtreecommitdiff
path: root/src/buffer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.cc')
-rw-r--r--src/buffer.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/buffer.cc b/src/buffer.cc
index 9650ee20..0ffdb9ae 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -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;