summaryrefslogtreecommitdiff
path: root/core/java/android/widget/SpellChecker.java
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-12-06 15:57:47 -0800
committerGilles Debunne <debunne@google.com>2011-12-06 15:57:47 -0800
commitf9bb1cd1fcff7079445dae494ce5d56276092c11 (patch)
tree3ae8d8232cea34053ec46fa7a68f79094b1e8d88 /core/java/android/widget/SpellChecker.java
parente98ae0a050d6ce4b3e2aec7c070a87922086c256 (diff)
parentfb72920209fb1bc13d7df257951b021d022e50d8 (diff)
resolved conflicts for merge of fb729202 to master
Change-Id: Ic571594b14f2822094d5c1aa4c4b1e9da4a2eae0
Diffstat (limited to 'core/java/android/widget/SpellChecker.java')
-rw-r--r--core/java/android/widget/SpellChecker.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java
index d03db10a8998..4bd7165786f1 100644
--- a/core/java/android/widget/SpellChecker.java
+++ b/core/java/android/widget/SpellChecker.java
@@ -272,9 +272,11 @@ public class SpellChecker implements SpellCheckerSessionListener {
((attributes & SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) > 0);
SpellCheckSpan spellCheckSpan = mSpellCheckSpans[j];
+
if (!isInDictionary && looksLikeTypo) {
createMisspelledSuggestionSpan(editable, suggestionsInfo, spellCheckSpan);
}
+
editable.removeSpan(spellCheckSpan);
break;
}
@@ -295,20 +297,21 @@ public class SpellChecker implements SpellCheckerSessionListener {
}, SPELL_PAUSE_DURATION);
}
- private void createMisspelledSuggestionSpan(Editable editable,
- SuggestionsInfo suggestionsInfo, SpellCheckSpan spellCheckSpan) {
+ private void createMisspelledSuggestionSpan(Editable editable, SuggestionsInfo suggestionsInfo,
+ SpellCheckSpan spellCheckSpan) {
final int start = editable.getSpanStart(spellCheckSpan);
final int end = editable.getSpanEnd(spellCheckSpan);
- if (start < 0 || end < 0) return; // span was removed in the meantime
+ if (start < 0 || end <= start) return; // span was removed in the meantime
// Other suggestion spans may exist on that region, with identical suggestions, filter
- // them out to avoid duplicates. First, filter suggestion spans on that exact region.
+ // them out to avoid duplicates.
SuggestionSpan[] suggestionSpans = editable.getSpans(start, end, SuggestionSpan.class);
final int length = suggestionSpans.length;
for (int i = 0; i < length; i++) {
final int spanStart = editable.getSpanStart(suggestionSpans[i]);
final int spanEnd = editable.getSpanEnd(suggestionSpans[i]);
if (spanStart != start || spanEnd != end) {
+ // Nulled (to avoid new array allocation) if not on that exact same region
suggestionSpans[i] = null;
}
}
@@ -355,6 +358,8 @@ public class SpellChecker implements SpellCheckerSessionListener {
SuggestionSpan suggestionSpan = new SuggestionSpan(mTextView.getContext(), suggestions,
SuggestionSpan.FLAG_EASY_CORRECT | SuggestionSpan.FLAG_MISSPELLED);
editable.setSpan(suggestionSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+ mTextView.invalidateRegion(start, end);
}
private class SpellParser {