Buffer: iterator_at prevents getting iterators on end of line
This commit is contained in:
parent
7e2f7f6715
commit
d7f934b7ca
|
@ -57,8 +57,9 @@ BufferIterator Buffer::iterator_at(const BufferCoord& line_and_column) const
|
||||||
if (m_lines.empty())
|
if (m_lines.empty())
|
||||||
return begin();
|
return begin();
|
||||||
|
|
||||||
BufferPos line = Kakoune::clamp<int>(0, m_lines.size() - 1, line_and_column.line);
|
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);
|
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);
|
return BufferIterator(*this, m_lines[line] + column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user