Go back to window lines ending at one past the end of the buffer line
Change Buffer::iterator_at so that this case is tolerated, and fixes the coord to next line start instead of clamping to last line char.
This commit is contained in:
parent
724b4198b0
commit
e6c4bed42b
|
@ -166,7 +166,12 @@ void Buffer::update_display_name()
|
|||
|
||||
BufferIterator Buffer::iterator_at(BufferCoord coord) const
|
||||
{
|
||||
return is_end(coord) ? end() : BufferIterator(*this, clamp(coord));
|
||||
// Tolerate one past the end of line
|
||||
if (not is_end(coord) and coord.column == m_lines[coord.line].length())
|
||||
coord = coord.line+1;
|
||||
|
||||
kak_assert(is_valid(coord));
|
||||
return {*this, coord};
|
||||
}
|
||||
|
||||
BufferCoord Buffer::clamp(BufferCoord coord) const
|
||||
|
|
|
@ -132,11 +132,11 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
|
|||
if (buffer_line >= buffer().line_count())
|
||||
break;
|
||||
auto beg_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column});
|
||||
auto end_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column});
|
||||
auto end_coord = setup.full_lines or end_byte == buffer()[buffer_line].length() ?
|
||||
buffer_line+1 : BufferCoord{buffer_line, end_byte};
|
||||
auto end_byte = setup.full_lines ?
|
||||
buffer()[buffer_line].length()
|
||||
: get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column});
|
||||
|
||||
lines.emplace_back(AtomList{ {buffer(), {buffer_line, beg_byte}, end_coord} });
|
||||
lines.emplace_back(AtomList{ {buffer(), {buffer_line, beg_byte}, {buffer_line, end_byte}} });
|
||||
}
|
||||
|
||||
m_display_buffer.compute_range();
|
||||
|
|
Loading…
Reference in New Issue
Block a user