Merge "Fix a bug in sentence detection when input is too long." into sc-dev am: 87d4c9a9ca
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14674299 Change-Id: Ib86c0b4966296d3100e349824c9825485b4bc584
This commit is contained in:
@@ -827,7 +827,7 @@ public class SpellChecker implements SpellCheckerSessionListener {
|
|||||||
// The offset should be rounded up to word boundary.
|
// The offset should be rounded up to word boundary.
|
||||||
int uncheckedLength = sentenceEnd - textChangeStart;
|
int uncheckedLength = sentenceEnd - textChangeStart;
|
||||||
if (uncheckedLength > MAX_SENTENCE_LENGTH) {
|
if (uncheckedLength > MAX_SENTENCE_LENGTH) {
|
||||||
sentenceEnd = findSeparator(sequence, sentenceStart + MAX_SENTENCE_LENGTH,
|
sentenceEnd = findSeparator(sequence, textChangeStart + MAX_SENTENCE_LENGTH,
|
||||||
sentenceEnd);
|
sentenceEnd);
|
||||||
sentenceStart = roundUpToWordStart(sequence, textChangeStart, sentenceStart);
|
sentenceStart = roundUpToWordStart(sequence, textChangeStart, sentenceStart);
|
||||||
} else {
|
} else {
|
||||||
@@ -835,7 +835,7 @@ public class SpellChecker implements SpellCheckerSessionListener {
|
|||||||
sentenceStart);
|
sentenceStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Range(sentenceStart, sentenceEnd);
|
return new Range<>(sentenceStart, Math.max(sentenceStart, sentenceEnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int roundUpToWordStart(CharSequence sequence, int position, int frontBoundary) {
|
private int roundUpToWordStart(CharSequence sequence, int position, int frontBoundary) {
|
||||||
|
|||||||
Reference in New Issue
Block a user