diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 0500907..72985ed 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1249,6 +1249,7 @@ void QLineEdit::selectAll()
 
 void QLineEdit::deselect()
 {
+    qDebug() << __FUNCTION__;
     Q_D(QLineEdit);
     d->control->deselect();
 }
@@ -1461,6 +1462,7 @@ bool QLineEdit::event(QEvent * e)
 void QLineEdit::mousePressEvent(QMouseEvent* e)
 {
     Q_D(QLineEdit);
+    qDebug() << __FUNCTION__ << e;
 
     d->mousePressPos = e->pos();
 
@@ -1518,6 +1520,8 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
             const bool select = (d->imHints & Qt::ImhNoPredictiveText);
 #endif
 #ifndef QT_NO_IM
+            qDebug() << __FUNCTION__ << e << "select=" << select
+                     << "composeMode=" << d->control->composeMode();
             if (d->control->composeMode() && select) {
                 int startPos = d->xToPos(d->mousePressPos.x());
                 int currentPos = d->xToPos(e->pos().x());
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 759e41a..1243852 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -48,6 +48,7 @@
 #ifndef QT_NO_GRAPHICSVIEW
 #include "qgraphicssceneevent.h"
 #endif
+#include <qdebug.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -307,6 +308,7 @@ void QWidgetLineControl::undo()
 */
 void QWidgetLineControl::setSelection(int start, int length)
 {
+    qDebug() << __FUNCTION__ << start << length;
     commitPreedit();
 
     if(start < 0 || start > (int)m_text.length()){
@@ -457,6 +459,10 @@ bool QWidgetLineControl::fixup() // this function assumes that validate currentl
 void QWidgetLineControl::moveCursor(int pos, bool mark)
 {
     commitPreedit();
+    qDebug() << __FUNCTION__
+             << "from" << m_cursor << "to" << pos
+             << (pos > m_cursor ? "right" : "left")
+             << "mark=" << mark;
 
     if (pos != m_cursor) {
         separate();
@@ -464,15 +470,24 @@ void QWidgetLineControl::moveCursor(int pos, bool mark)
             pos = pos > m_cursor ? nextMaskBlank(pos) : prevMaskBlank(pos);
     }
     if (mark) {
-        int anchor;
-        if (m_selend > m_selstart && m_cursor == m_selstart)
+        int anchor;        
+        if (m_selend > m_selstart && m_cursor == m_selstart) {
+            qDebug() << "Branch1: anchor = m_selend";
             anchor = m_selend;
-        else if (m_selend > m_selstart && m_cursor == m_selend)
+        } else if (m_selend > m_selstart && m_cursor == m_selend) {
+            qDebug() << "Branch2: anchor = m_selstart";
             anchor = m_selstart;
-        else
+        } else {
+            qDebug() << "Branch3: anchor = m_cursor";
             anchor = m_cursor;
+        }
+        qDebug() << __FUNCTION__ << "anchor=" << anchor
+                 << "old m_selstart=" << m_selstart
+                  << "old m_selend=" << m_selend;
         m_selstart = qMin(anchor, pos);
         m_selend = qMax(anchor, pos);
+        qDebug() << __FUNCTION__ << "m_selstart=" << m_selstart
+                  << "m_selend=" << m_selend;
         updateDisplayText();
     } else {
         internalDeselect();
@@ -608,6 +623,8 @@ void QWidgetLineControl::draw(QPainter *painter, const QPoint &offset, const QRe
     QVector<QTextLayout::FormatRange> selections;
     if (flags & DrawSelections) {
         QTextLayout::FormatRange o;
+        qDebug() << __FUNCTION__ << "m_selstart=" << m_selstart
+                 << "m_selend=" << m_selend;
         if (m_selstart < m_selend) {
             o.start = m_selstart;
             o.length = m_selend - m_selstart;
@@ -646,6 +663,7 @@ void QWidgetLineControl::draw(QPainter *painter, const QPoint &offset, const QRe
 */
 void QWidgetLineControl::selectWordAtPos(int cursor)
 {
+    qDebug() << '>' << __FUNCTION__ << "cursor=" << cursor;
     int next = cursor + 1;
     if(next > end())
         --next;
@@ -656,6 +674,7 @@ void QWidgetLineControl::selectWordAtPos(int cursor)
     while (end > cursor && m_text[end-1].isSpace())
         --end;
     moveCursor(end, true);
+    qDebug() << '<' << __FUNCTION__ ;
 }
 
 /*!
@@ -672,6 +691,7 @@ void QWidgetLineControl::selectWordAtPos(int cursor)
 */
 bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool edited)
 {
+    qDebug() << __FUNCTION__;
     Q_UNUSED(update)
 
     if (m_textDirty) {
