negative coordinates are invalid

This commit is contained in:
Maxime Coste 2014-05-13 18:59:22 +01:00
parent 8ab1f58594
commit 7bc73b7ef9

View File

@ -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);