Skip to content

Commit 24d146b

Browse files
committed
Fix the boundary of the sentence level spell check
Bug: 6400290 Change-Id: Ifb3b2f4034a1717369c63206611e5b6c441fded5
1 parent fc8e5ea commit 24d146b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

core/java/android/widget/SpellChecker.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,16 @@ private void removeRangeSpan(Editable editable) {
457457
public void parse() {
458458
Editable editable = (Editable) mTextView.getText();
459459
// Iterate over the newly added text and schedule new SpellCheckSpans
460-
final int start = editable.getSpanStart(mRange);
460+
final int start;
461+
if (mIsSentenceSpellCheckSupported) {
462+
// TODO: Find the start position of the sentence.
463+
// Set span with the context
464+
start = Math.max(
465+
0, editable.getSpanStart(mRange) - MIN_SENTENCE_LENGTH);
466+
} else {
467+
start = editable.getSpanStart(mRange);
468+
}
469+
461470
final int end = editable.getSpanEnd(mRange);
462471

463472
int wordIteratorWindowEnd = Math.min(end, start + WORD_ITERATOR_INTERVAL);
@@ -512,9 +521,7 @@ public void parse() {
512521
return;
513522
}
514523
// TODO: Find the start position of the sentence.
515-
// Set span with the context
516-
final int spellCheckStart = Math.max(
517-
0, Math.min(wordStart, regionEnd - MIN_SENTENCE_LENGTH));
524+
final int spellCheckStart = wordStart;
518525
if (regionEnd <= spellCheckStart) {
519526
return;
520527
}

0 commit comments

Comments
 (0)