am 671b2a57: Merge "Fix for IndexOutOfBounds in text pasting." into gingerbread
Merge commit '671b2a57bb5a2a8669d1dabe65b4080804ee350a' into gingerbread-plus-aosp * commit '671b2a57bb5a2a8669d1dabe65b4080804ee350a': Fix for IndexOutOfBounds in text pasting.
This commit is contained in:
@@ -7490,16 +7490,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
if (Character.isSpaceChar(paste.charAt(0))) {
|
if (Character.isSpaceChar(paste.charAt(0))) {
|
||||||
if (min > 0 && Character.isSpaceChar(mTransformed.charAt(min - 1))) {
|
if (min > 0 && Character.isSpaceChar(mTransformed.charAt(min - 1))) {
|
||||||
// Two spaces at beginning of paste: remove one
|
// Two spaces at beginning of paste: remove one
|
||||||
|
final int originalLength = mText.length();
|
||||||
((Editable) mText).replace(min - 1, min, "");
|
((Editable) mText).replace(min - 1, min, "");
|
||||||
min = min - 1;
|
// Due to filters, there is no garantee that exactly one character was
|
||||||
max = max - 1;
|
// removed. Count instead.
|
||||||
|
final int delta = mText.length() - originalLength;
|
||||||
|
min += delta;
|
||||||
|
max += delta;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (min > 0 && !Character.isSpaceChar(mTransformed.charAt(min - 1))) {
|
if (min > 0 && !Character.isSpaceChar(mTransformed.charAt(min - 1))) {
|
||||||
// No space at beginning of paste: add one
|
// No space at beginning of paste: add one
|
||||||
|
final int originalLength = mText.length();
|
||||||
((Editable) mText).replace(min, min, " ");
|
((Editable) mText).replace(min, min, " ");
|
||||||
min = min + 1;
|
// Taking possible filters into account as above.
|
||||||
max = max + 1;
|
final int delta = mText.length() - originalLength;
|
||||||
|
min += delta;
|
||||||
|
max += delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user