Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5915c885 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Bug 5237623: word no longer underlined after replacement

When replacing a word, we need to remove *all* misspelled
suggestion spans, not just the one which triggered that popup.

Change-Id: I7be17ac626b26123b029f5e10c1e2eaa5f94d67c
parent 338140f7
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -249,7 +249,6 @@ public class SpellChecker implements SpellCheckerSessionListener {
            final int spanEnd = editable.getSpanEnd(suggestionSpans[i]);
            final int spanEnd = editable.getSpanEnd(suggestionSpans[i]);
            if (spanStart != start || spanEnd != end) {
            if (spanStart != start || spanEnd != end) {
                suggestionSpans[i] = null;
                suggestionSpans[i] = null;
                break;
            }
            }
        }
        }


+8 −11
Original line number Original line Diff line number Diff line
@@ -9607,15 +9607,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            SpannableStringBuilder text = new SpannableStringBuilder();
            SpannableStringBuilder text = new SpannableStringBuilder();
            TextAppearanceSpan highlightSpan = new TextAppearanceSpan(mContext,
            TextAppearanceSpan highlightSpan = new TextAppearanceSpan(mContext,
                    android.R.style.TextAppearance_SuggestionHighlight);
                    android.R.style.TextAppearance_SuggestionHighlight);

            void removeMisspelledFlag() {
                int suggestionSpanFlags = suggestionSpan.getFlags();
                if ((suggestionSpanFlags & SuggestionSpan.FLAG_MISSPELLED) > 0) {
                    suggestionSpanFlags &= ~SuggestionSpan.FLAG_MISSPELLED;
                    suggestionSpanFlags &= ~SuggestionSpan.FLAG_EASY_CORRECT;
                    suggestionSpan.setFlags(suggestionSpanFlags);
                }
            }
        }
        }


        private class SuggestionAdapter extends BaseAdapter {
        private class SuggestionAdapter extends BaseAdapter {
@@ -9931,6 +9922,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    suggestionSpansStarts[i] = editable.getSpanStart(suggestionSpan);
                    suggestionSpansStarts[i] = editable.getSpanStart(suggestionSpan);
                    suggestionSpansEnds[i] = editable.getSpanEnd(suggestionSpan);
                    suggestionSpansEnds[i] = editable.getSpanEnd(suggestionSpan);
                    suggestionSpansFlags[i] = editable.getSpanFlags(suggestionSpan);
                    suggestionSpansFlags[i] = editable.getSpanFlags(suggestionSpan);

                    // Remove potential misspelled flags
                    int suggestionSpanFlags = suggestionSpan.getFlags();
                    if ((suggestionSpanFlags & SuggestionSpan.FLAG_MISSPELLED) > 0) {
                        suggestionSpanFlags &= ~SuggestionSpan.FLAG_MISSPELLED;
                        suggestionSpanFlags &= ~SuggestionSpan.FLAG_EASY_CORRECT;
                        suggestionSpan.setFlags(suggestionSpanFlags);
                    }
                }
                }


                final int suggestionStart = suggestionInfo.suggestionStart;
                final int suggestionStart = suggestionInfo.suggestionStart;
@@ -9939,8 +9938,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        suggestionStart, suggestionEnd).toString();
                        suggestionStart, suggestionEnd).toString();
                editable.replace(spanStart, spanEnd, suggestion);
                editable.replace(spanStart, spanEnd, suggestion);


                suggestionInfo.removeMisspelledFlag();

                // Notify source IME of the suggestion pick. Do this before swaping texts.
                // Notify source IME of the suggestion pick. Do this before swaping texts.
                if (!TextUtils.isEmpty(
                if (!TextUtils.isEmpty(
                        suggestionInfo.suggestionSpan.getNotificationTargetClassName())) {
                        suggestionInfo.suggestionSpan.getNotificationTargetClassName())) {