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:
Maxime Coste 2017-06-15 17:25:37 +01:00
parent 724b4198b0
commit e6c4bed42b
2 changed files with 10 additions and 5 deletions

View File

@ -166,7 +166,12 @@ void Buffer::update_display_name()
BufferIterator Buffer::iterator_at(BufferCoord coord) const 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 BufferCoord Buffer::clamp(BufferCoord coord) const

View File

@ -132,11 +132,11 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
if (buffer_line >= buffer().line_count()) if (buffer_line >= buffer().line_count())
break; break;
auto beg_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column}); 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_byte = setup.full_lines ?
auto end_coord = setup.full_lines or end_byte == buffer()[buffer_line].length() ? buffer()[buffer_line].length()
buffer_line+1 : BufferCoord{buffer_line, end_byte}; : 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(); m_display_buffer.compute_range();