diff --git a/src/buffer.inl.hh b/src/buffer.inl.hh index 9cfa2d0f..5375d993 100644 --- a/src/buffer.inl.hh +++ b/src/buffer.inl.hh @@ -52,6 +52,9 @@ inline ByteCount Buffer::offset(ByteCoord c) const inline bool Buffer::is_valid(ByteCoord c) const { + if (c.line < 0 or c.column < 0) + return false; + return (c.line < line_count() and c.column < m_lines[c.line].length()) or (c.line == line_count() - 1 and c.column == m_lines.back().length()) or (c.line == line_count() and c.column == 0);