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

Commit 0656bc32 authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Bug 4579629. Send before and after text when suggestion is picked."

parents 19436972 4d802808
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -8574,11 +8574,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    final String originalText = mText.subSequence(spanStart, spanEnd).toString();
                    ((Editable) mText).replace(spanStart, spanEnd, suggestion);

                    // Swap text content between actual text and Suggestion span
                    String[] suggestions = suggestionInfo.suggestionSpan.getSuggestions();
                    suggestions[suggestionInfo.suggestionIndex] = originalText;

                    // Notify source IME of the suggestion pick
                    // Notify source IME of the suggestion pick. Do this before swaping texts.
                    if (!TextUtils.isEmpty(
                            suggestionInfo.suggestionSpan.getNotificationTargetClassName())) {
                        InputMethodManager imm = InputMethodManager.peekInstance();
@@ -8586,6 +8582,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                                suggestionInfo.suggestionIndex);
                    }

                    // Swap text content between actual text and Suggestion span
                    String[] suggestions = suggestionInfo.suggestionSpan.getSuggestions();
                    suggestions[suggestionInfo.suggestionIndex] = originalText;

                    // Restore previous SuggestionSpans
                    final int lengthDifference = suggestion.length() - (spanEnd - spanStart);
                    for (int i = 0; i < length; i++) {