diff --git a/escher/src/text_area.cpp b/escher/src/text_area.cpp index e3706f678..d08a30437 100644 --- a/escher/src/text_area.cpp +++ b/escher/src/text_area.cpp @@ -549,9 +549,9 @@ void TextArea::ContentView::moveCursorGeo(int deltaX, int deltaY) { } void TextArea::selectUpDown(bool up) { - const char * currentCursorLocation = contentView()->cursorLocation(); + const char * previousCursorLocation = contentView()->cursorLocation(); contentView()->moveCursorGeo(0, up ? -1 : 1); const char * newCursorLocation = contentView()->cursorLocation(); - contentView()->addSelection(up ? newCursorLocation : currentCursorLocation, up ? currentCursorLocation : newCursorLocation); + contentView()->addSelection(up ? newCursorLocation : previousCursorLocation, up ? previousCursorLocation : newCursorLocation); scrollToCursor(); } diff --git a/escher/src/text_input.cpp b/escher/src/text_input.cpp index bf19fb01c..8bf2ce60e 100644 --- a/escher/src/text_input.cpp +++ b/escher/src/text_input.cpp @@ -26,11 +26,6 @@ KDRect TextInput::ContentView::cursorRect() { } void TextInput::ContentView::addSelection(const char * left, const char * right) { - if ((left == m_selectionStart && right <= m_selectionEnd) - || (right == m_selectionEnd && left >= m_selectionStart)) - { - return; - } bool emptySelection = selectionIsEmpty(); if (emptySelection) { m_selectionStart = left; @@ -40,10 +35,20 @@ void TextInput::ContentView::addSelection(const char * left, const char * right) } else if (right == m_selectionStart) { m_selectionStart = left; } else if (right == m_selectionEnd) { - m_selectionEnd = left; + if (left >= m_selectionStart) { + m_selectionEnd = left; + } else { + m_selectionEnd = m_selectionStart; + m_selectionStart = left; + } } else { assert(left == m_selectionStart); - m_selectionStart = right; + if (right <= m_selectionEnd) { + m_selectionStart = right; + } else { + m_selectionStart = m_selectionEnd; + m_selectionEnd = right; + } } reloadRectFromAndToPositions(left, right); if (m_selectionStart == m_selectionEnd) {