Editor: avoid end of lines when moving selection

This commit is contained in:
Maxime Coste 2012-11-08 13:37:29 +01:00
parent bdd0758ee2
commit 3a34fae9a7

View File

@ -133,6 +133,7 @@ void Editor::move_selections(CharCount offset, SelectMode mode)
: utf8::previous(buffer().iterator_at_line_end(last)); : utf8::previous(buffer().iterator_at_line_end(last));
last = utf8::advance(last, limit, offset); last = utf8::advance(last, limit, offset);
sel.selection = Selection(mode == SelectMode::Extend ? sel.first() : last, last); sel.selection = Selection(mode == SelectMode::Extend ? sel.first() : last, last);
sel.selection.avoid_eol();
} }
merge_overlapping(m_selections); merge_overlapping(m_selections);
} }
@ -146,6 +147,7 @@ void Editor::move_selections(LineCount offset, SelectMode mode)
pos.line += offset; pos.line += offset;
BufferIterator last = utf8::finish(m_buffer->iterator_at(pos, true)); BufferIterator last = utf8::finish(m_buffer->iterator_at(pos, true));
sel.selection = Selection(mode == SelectMode::Extend ? sel.first() : last, last); sel.selection = Selection(mode == SelectMode::Extend ? sel.first() : last, last);
sel.selection.avoid_eol();
} }
merge_overlapping(m_selections); merge_overlapping(m_selections);
} }