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

Commit e3de3180 authored by wangjing's avatar wangjing Committed by Linux Build Service Account
Browse files

base: App crash when select suggestion's length more than specified.

App crashed by catch IndexOutOfBoundsException which raised
by check span range when select suggested string.The root
cause is that the editor will truncate the suggested string
which length is more than it specified, but it also set span
use the suggestion's original length.

Update the suggestion's real length after editor replace the
original string to suggested.

Change-Id: I2d765701934a9e68be172cb87a104590f3cdeceb
CRs-Fixed: 532211
parent c5bbfc93
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2760,7 +2760,8 @@ public class Editor {
                suggestions[suggestionInfo.suggestionIndex] = originalText;

                // Restore previous SuggestionSpans
                final int lengthDifference = suggestion.length() - (spanEnd - spanStart);
                final int realSuggestionLength = mTextView.getText().toString().length();
                final int lengthDifference = realSuggestionLength - (spanEnd - spanStart);
                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