// ----------------------------------------------------------------------------
 
 #ifdef __GNUG__
-    #pragma implementation "textctrl.h"
+    #pragma implementation "univtextctrl.h"
 #endif
 
 #include "wx/wxprec.h"
     }
     else // valid sel range
     {
+        // remember the 'to' position as the current position, used to move the
+        // caret there later
+        wxTextPos toOrig = to;
+
         OrderPositions(from, to);
 
         wxCHECK_RET( to <= GetLastPosition(),
         }
         //else: nothing to do
 
-        // the insertion point is put at the end of selection
-        DoSetInsertionPoint(to);
+        // the insertion point is put at the location where the caret was moved
+        DoSetInsertionPoint(toOrig);
     }
 }