Skip to content

Commit 14ed50a

Browse files
Gilles DebunneFabrice Di Meglio
authored andcommitted
Bug 5332065: IOOB in case the suggestionSpan has been removed
I don't understand how the SuggSpan that has been tapped to display the popup can have disappeared when an item is clicked. This problem seems specific to monkey test with a race condition somewhere. Change-Id: I447b6563a1b959dc3c1ead31cde2d9bcad369765
1 parent a6ccaa7 commit 14ed50a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/java/android/widget/TextView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9879,13 +9879,16 @@ private void highlightTextDifferences(SuggestionInfo suggestionInfo, int unionSt
98799879

98809880
@Override
98819881
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
9882+
hide();
9883+
98829884
if (view instanceof TextView) {
98839885
TextView textView = (TextView) view;
98849886
Editable editable = (Editable) mText;
98859887

98869888
SuggestionInfo suggestionInfo = mSuggestionInfos[position];
98879889
final int spanStart = editable.getSpanStart(suggestionInfo.suggestionSpan);
98889890
final int spanEnd = editable.getSpanEnd(suggestionInfo.suggestionSpan);
9891+
if (spanStart < 0 || spanEnd < 0) return; // Span has been removed
98899892
final String originalText = mText.subSequence(spanStart, spanEnd).toString();
98909893

98919894
if (suggestionInfo.suggestionIndex < 0) {
@@ -9947,7 +9950,6 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
99479950
Selection.setSelection(editable, spanEnd + lengthDifference);
99489951
}
99499952
}
9950-
hide();
99519953
}
99529954
}
99539955

0 commit comments

Comments
 (0)