diff options
| author | 2011-11-29 09:59:25 -0800 | |
|---|---|---|
| committer | 2011-11-29 09:59:25 -0800 | |
| commit | 0dca407eede3d85a0185718f4993c2b09d1cc658 (patch) | |
| tree | 3ed26d7e3ad7dd1e7cc27d81f6bc503bb7da4ed9 | |
| parent | 834c2870fa422098b3728ae26099b3030994f86f (diff) | |
| parent | 7be31bd96a4cc71ebc2539573f062fa53cc7cb05 (diff) | |
am 7be31bd9: Merge "IOOB in text selection." into ics-mr1
* commit '7be31bd96a4cc71ebc2539573f062fa53cc7cb05':
IOOB in text selection.
| -rw-r--r-- | core/java/android/widget/TextView.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 185cfa932c51..2a31193b9c14 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -7613,6 +7613,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener list.get(i).onTextChanged(text, start, before, after); } } + + updateSpellCheckSpans(start, start + after); + + // Hide the controllers as soon as text is modified (typing, procedural...) + // We do not hide the span controllers, since they can be added when a new text is + // inserted into the text view (voice IME). + hideCursorControllers(); } /** @@ -7652,15 +7659,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener sendOnTextChanged(buffer, start, before, after); onTextChanged(buffer, start, before, after); - - updateSpellCheckSpans(start, start + after); - - // Hide the controllers if the amount of content changed - if (before != after) { - // We do not hide the span controllers, as they can be added when a new text is - // inserted into the text view - hideCursorControllers(); - } } /** @@ -10823,7 +10821,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Handles can not cross and selection is at least one character final int selectionEnd = getSelectionEnd(); - if (offset >= selectionEnd) offset = selectionEnd - 1; + if (offset >= selectionEnd) offset = Math.max(0, selectionEnd - 1); positionAtCursorOffset(offset, false); } @@ -10865,7 +10863,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // Handles can not cross and selection is at least one character final int selectionStart = getSelectionStart(); - if (offset <= selectionStart) offset = selectionStart + 1; + if (offset <= selectionStart) offset = Math.min(selectionStart + 1, mText.length()); positionAtCursorOffset(offset, false); } |