зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1123514 - Correctly calculate text replacement offset; r=esawin
Fix a mistake in calculating the correct offset for one of the replacement steps, which caused the IndexOutOfBoundsException. The old code used `oldEnd` for the second text replacement without taking into account the offset change as a result of the first text replacement that was already performed. The new code correctly takes the offset, `delta`, into account.
This commit is contained in:
Родитель
107b9eb939
Коммит
ffd6532bd7
|
@ -1220,13 +1220,14 @@ final class GeckoEditable extends JNIObject
|
|||
|
||||
// Then replace part of the text after the sequence.
|
||||
final int actionStart = indexInText + start;
|
||||
final int actionEnd = actionStart + action.mEnd - action.mStart;
|
||||
final int delta = actionStart - action.mStart;
|
||||
final int actionEnd = delta + action.mEnd;
|
||||
|
||||
final Spanned currentText = mText.getCurrentText();
|
||||
final boolean resetSelStart = Selection.getSelectionStart(currentText) == actionEnd;
|
||||
final boolean resetSelEnd = Selection.getSelectionEnd(currentText) == actionEnd;
|
||||
|
||||
mText.currentReplace(actionEnd, oldEnd, text.subSequence(
|
||||
mText.currentReplace(actionEnd, delta + oldEnd, text.subSequence(
|
||||
indexInText + action.mSequence.length(), text.length()));
|
||||
|
||||
// The replacement above may have shifted our selection, if the selection
|
||||
|
|
Загрузка…
Ссылка в новой задаче