src/gui/widgets/qlineedit.cpp
changeset 23 89e065397ea6
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/src/gui/widgets/qlineedit.cpp	Fri May 14 16:40:13 2010 +0300
+++ b/src/gui/widgets/qlineedit.cpp	Thu May 27 13:40:48 2010 +0300
@@ -738,8 +738,14 @@
         setText(oldText);
         return false;
     }
-    setCursorPosition(newPos);
-    setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag));
+    int selstart = qMin(newMarkAnchor, newMarkDrag);
+    int sellength = qAbs(newMarkAnchor - newMarkDrag);
+    if (selstart == newPos) {
+        selstart = qMax(newMarkAnchor, newMarkDrag);
+        sellength = -sellength;
+    }
+    //setSelection also set the position
+    setSelection(selstart, sellength);
     return true;
 }
 #endif //QT3_SUPPORT