diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 133c843f..2ecded59 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -93,6 +93,9 @@ DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& whe DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& where, iterator start) { + if (where < start->begin()) + return end(); + return std::upper_bound(start, end(), where, [](const BufferIterator& where, const DisplayAtom& atom) { return where < atom.end(); });