diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-10-31 14:28:03 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-10-31 14:28:03 +0100 |
| commit | c9478191541e49351638db8a3efd262f19c700f4 (patch) | |
| tree | 3d9cba3db060bd934ab9cd0b26626faf0a6fba09 /src/buffer.cc | |
| parent | 74731b0d0fe840dff6815536dce88862351318e9 (diff) | |
Fix buffer iterator_at_line_{begin,end}(LineCount)
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 6 |
1 files 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 }); } |
