Fix utf8 handling when moving selection up/down

This commit is contained in:
Maxime Coste 2013-02-26 18:52:49 +01:00
parent 3d19111570
commit 0f413607c2

View File

@ -178,8 +178,10 @@ void Editor::move_selections(LineCount offset, SelectMode mode)
for (auto& sel : m_selections) for (auto& sel : m_selections)
{ {
BufferCoord pos = sel.last().coord(); BufferCoord pos = sel.last().coord();
CharCount column = utf8::distance(m_buffer->iterator_at_line_begin(pos.line), sel.last());
pos.line += offset; pos.line += offset;
BufferIterator last = utf8::finish(m_buffer->iterator_at(pos, true)); BufferIterator last = utf8::advance(m_buffer->iterator_at_line_begin(pos.line),
m_buffer->iterator_at_line_end(pos.line), column);
sel.first() = mode == SelectMode::Extend ? sel.first() : last; sel.first() = mode == SelectMode::Extend ? sel.first() : last;
sel.last() = last; sel.last() = last;
sel.avoid_eol(); sel.avoid_eol();