From c9478191541e49351638db8a3efd262f19c700f4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 31 Oct 2012 14:28:03 +0100 Subject: [PATCH] Fix buffer iterator_at_line_{begin,end}(LineCount) --- src/buffer.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index 91e5f405..62be491e 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -87,7 +87,9 @@ BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) co BufferIterator Buffer::iterator_at_line_begin(LineCount line) const { - return BufferIterator(*this, clamp({ line, 0 })); + line = Kakoune::clamp(line, 0_line, line_count()-1); + assert(line_length(line) > 0); + return BufferIterator(*this, { line, 0 }); } BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const @@ -99,7 +101,7 @@ BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) cons BufferIterator Buffer::iterator_at_line_end(LineCount line) const { - line = std::min(line, line_count()-1); + line = Kakoune::clamp(line, 0_line, line_count()-1); assert(line_length(line) > 0); return ++BufferIterator(*this, { line, line_length(line) - 1 }); }