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

Commit 94aa4fd2 authored by Abhishek Arpure's avatar Abhishek Arpure Committed by Linux Build Service Account
Browse files

Applications crash observed while selecting words from suggestion list

While selecting words from suggestion list, applications are crashing as
textview span are going out of index. For textinput where spaces are not
allowed length difference shall be calculated properly to avoid Index
out of bound situations.

Change-Id: I360318cf9241abbb7f58ad1ddf3f3c8d364f17d1
CRs-Fixed: 642057
parent bee2b92b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2761,7 +2761,13 @@ public class Editor {

                // Restore previous SuggestionSpans
                final int realSuggestionLength = mTextView.getText().toString().length();
                final int lengthDifference = realSuggestionLength - (spanEnd - spanStart);
                int lengthDifference = suggestion.length() - (spanEnd - spanStart);
                final int realSuggestionDiff = realSuggestionLength - (spanEnd - spanStart);

                if (realSuggestionDiff < lengthDifference) {
                    lengthDifference = realSuggestionDiff;
                }

                for (int i = 0; i < length; i++) {
                    // Only spans that include the modified region make sense after replacement
                    // Spans partially included in the replaced region are removed, there is no