Skip to content

Commit 979de90

Browse files
committed
Fix the first boundary of the sentence level spell check
Change-Id: I7c7659c921103d31f9909c14850088aef0d2eb19
1 parent ad04c9c commit 979de90

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/java/android/widget/SpellChecker.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class SpellChecker implements SpellCheckerSessionListener {
6060
// Pause between each spell check to keep the UI smooth
6161
private final static int SPELL_PAUSE_DURATION = 400; // milliseconds
6262

63+
private static final int MIN_SENTENCE_LENGTH = 50;
64+
6365
private static final int USE_SPAN_RANGE = -1;
6466

6567
private final TextView mTextView;
@@ -508,11 +510,10 @@ public void parse() {
508510
if (wordEnd < start) {
509511
return;
510512
}
511-
wordStart = regionEnd;
512513
// TODO: Find the start position of the sentence.
513514
// Set span with the context
514515
final int spellCheckStart = Math.max(
515-
0, Math.min(wordStart, regionEnd - WORD_ITERATOR_INTERVAL));
516+
0, Math.min(wordStart, regionEnd - MIN_SENTENCE_LENGTH));
516517
if (regionEnd <= spellCheckStart) {
517518
return;
518519
}
@@ -530,6 +531,7 @@ public void parse() {
530531
&& (selectionEnd < spellCheckStart || selectionStart > regionEnd)) {
531532
addSpellCheckSpan(editable, spellCheckStart, regionEnd);
532533
}
534+
wordStart = regionEnd;
533535
} else {
534536
while (wordStart <= end) {
535537
if (wordEnd >= start && wordEnd > wordStart) {

0 commit comments

Comments
 (0)