BufferIterator: fix operator+

This commit is contained in:
Maxime Coste 2012-08-07 23:18:37 +02:00
parent b0ed0e37b7
commit dd05d6c6f5

View File

@ -138,7 +138,7 @@ inline BufferIterator BufferIterator::operator+(BufferSize size) const
if (m_buffer->m_lines[i].start > o) if (m_buffer->m_lines[i].start > o)
return BufferIterator(*m_buffer, { i-1, o - m_buffer->m_lines[i-1].start }); return BufferIterator(*m_buffer, { i-1, o - m_buffer->m_lines[i-1].start });
} }
int last_line = m_buffer->line_count() - 1; int last_line = std::max(0, m_buffer->line_count() - 1);
return BufferIterator(*m_buffer, { last_line, o - m_buffer->m_lines[last_line].start }); return BufferIterator(*m_buffer, { last_line, o - m_buffer->m_lines[last_line].start });
} }
return operator-(-size); return operator-(-size);