summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJames Cook <jamescook@google.com>2015-03-10 17:42:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-10 17:42:48 +0000
commit2a914cb3aef4963abc0406db1bfd42f0519ac3f3 (patch)
treefb7d06ee8d1cde288d70dda48d80d954cc676e6d /core
parentb1febc7f89d244e0dec26e9274960fea7560e4b6 (diff)
parent900185d00359661e185c3b328f40a4d572ae03f9 (diff)
downloadframeworks_base-2a914cb3aef4963abc0406db1bfd42f0519ac3f3.zip
frameworks_base-2a914cb3aef4963abc0406db1bfd42f0519ac3f3.tar.gz
frameworks_base-2a914cb3aef4963abc0406db1bfd42f0519ac3f3.tar.bz2
Merge "Handle undo in TextView fields with no cursor"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/Editor.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 0f99e88..cc44577 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -4887,9 +4887,10 @@ public class Editor {
text.insert(newTextInsertAt, newText);
}
}
- // Restore the cursor position.
+ // Restore the cursor position. If there wasn't an old cursor (newCursorPos == -1) then
+ // don't explicitly set it and rely on SpannableStringBuilder to position it.
// TODO: Select all the text that was undone.
- if (newCursorPos <= text.length()) {
+ if (0 <= newCursorPos && newCursorPos <= text.length()) {
Selection.setSelection(text, newCursorPos);
}
}