fix Editor::move_selections(LineCount...) on buffer bounds
This commit is contained in:
parent
cc70e3ed70
commit
cf1f26ac91
|
@ -199,11 +199,10 @@ void Editor::move_selections(LineCount offset, SelectMode mode)
|
||||||
kak_assert(mode == SelectMode::Replace or mode == SelectMode::Extend);
|
kak_assert(mode == SelectMode::Replace or mode == SelectMode::Extend);
|
||||||
for (auto& sel : m_selections)
|
for (auto& sel : m_selections)
|
||||||
{
|
{
|
||||||
auto pos = sel.last();
|
CharCount column = m_buffer->char_distance(sel.last().line, sel.last());
|
||||||
CharCount column = m_buffer->char_distance(pos.line, pos);
|
auto line = clamp(sel.last().line + offset, 0_line, m_buffer->line_count()-1);
|
||||||
pos.line += offset;
|
column = std::min(column, m_buffer->line_content(line).char_length()-1);
|
||||||
auto last = std::min(m_buffer->char_advance(pos.line, column),
|
BufferCoord last = m_buffer->char_advance(line, column);
|
||||||
m_buffer->char_prev(pos.line+1));
|
|
||||||
sel.first() = mode == SelectMode::Extend ? sel.first() : last;
|
sel.first() = mode == SelectMode::Extend ? sel.first() : last;
|
||||||
sel.last() = last;
|
sel.last() = last;
|
||||||
avoid_eol(*m_buffer, sel);
|
avoid_eol(*m_buffer, sel);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user