Automated import from //branches/master/...@141151,141151
diff --git a/core/java/com/android/internal/widget/EditStyledText.java b/core/java/com/android/internal/widget/EditStyledText.java
index da10d74..3da9753 100644
--- a/core/java/com/android/internal/widget/EditStyledText.java
+++ b/core/java/com/android/internal/widget/EditStyledText.java
@@ -471,6 +471,7 @@
             if (DBG) {
                 Log.d(LOG_TAG, "--- onStartEdit");
             }
+            Log.d(LOG_TAG, "--- onstartedit:" + this.getSelectionStart() + this.getSelectionEnd());
             handleResetEdit();
             mEST.notifyStateChanged(mMode, mState);
         }
@@ -855,6 +856,7 @@
             if (DBG) {
                 Log.d(LOG_TAG, "Reset Editor");
             }
+            blockSoftKey();
             handleCancel();
             mEditFlag = true;
             mEST.setHintMessage(HINT_MSG_SELECT_START);
@@ -967,8 +969,7 @@
             }
             int pos = current;
             for (; pos > 0; pos--) {
-                if (text.charAt(pos) == '\n') {
-                    pos++;
+                if (text.charAt(pos - 1) == '\n') {
                     break;
                 }
             }
@@ -982,7 +983,7 @@
             }
             int pos = current;
             for (; pos < text.length(); pos++) {
-                if (text.charAt(pos) == '\n') {
+                if (pos > 0 && text.charAt(pos - 1) == '\n') {
                     break;
                 }
             }