Buffer: iterator_at prevents getting iterators on end of line

This commit is contained in:
Maxime Coste 2011-10-19 14:25:13 +00:00
parent 7e2f7f6715
commit d7f934b7ca

View File

@ -57,8 +57,9 @@ BufferIterator Buffer::iterator_at(const BufferCoord& line_and_column) const
if (m_lines.empty())
return begin();
BufferPos line = Kakoune::clamp<int>(0, m_lines.size() - 1, line_and_column.line);
BufferPos column = Kakoune::clamp<int>(0, line_length(line), line_and_column.column);
BufferPos line = Kakoune::clamp<int>(0, m_lines.size() - 1, line_and_column.line);
int col_max = std::max(0, line_length(line) - 1);
BufferPos column = Kakoune::clamp<int>(0, col_max, line_and_column.column);
return BufferIterator(*this, m_lines[line] + column);
}