mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
* commit '3bd8eee3e8c3e89539578a4231661819de65c804': Fix an IOOB exception
This commit is contained in:
commit
78bb2dd945
@ -429,7 +429,7 @@ public class SuggestedWords {
|
|||||||
*/
|
*/
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
public SuggestedWordInfo getTypedWordInfoOrNull() {
|
public SuggestedWordInfo getTypedWordInfoOrNull() {
|
||||||
if (this == EMPTY) {
|
if (SuggestedWords.INDEX_OF_TYPED_WORD >= size()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final SuggestedWordInfo info = getInfo(SuggestedWords.INDEX_OF_TYPED_WORD);
|
final SuggestedWordInfo info = getInfo(SuggestedWords.INDEX_OF_TYPED_WORD);
|
||||||
|
@ -148,5 +148,15 @@ public class SuggestedWordsTests extends AndroidTestCase {
|
|||||||
|
|
||||||
// Make sure getTypedWordInfoOrNull() returns null.
|
// Make sure getTypedWordInfoOrNull() returns null.
|
||||||
assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
|
assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
|
||||||
|
|
||||||
|
final SuggestedWords emptySuggestedWords = new SuggestedWords(
|
||||||
|
new ArrayList<SuggestedWordInfo>(), null /* rawSuggestions */,
|
||||||
|
false /* typedWordValid */,
|
||||||
|
false /* willAutoCorrect */,
|
||||||
|
false /* isObsoleteSuggestions */,
|
||||||
|
SuggestedWords.INPUT_STYLE_NONE);
|
||||||
|
assertNull(emptySuggestedWords.getTypedWordInfoOrNull());
|
||||||
|
|
||||||
|
assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user