Fix a bug with common objects.
Bug: 5961179 Change-Id: I452efc552c6ab390931f25557d7aee5a64bf054e
This commit is contained in:
parent
a27cb62390
commit
a7f2500001
3 changed files with 12 additions and 8 deletions
|
@ -51,6 +51,8 @@ public class LastComposedWord {
|
||||||
public static final LastComposedWord NOT_A_COMPOSED_WORD =
|
public static final LastComposedWord NOT_A_COMPOSED_WORD =
|
||||||
new LastComposedWord(null, null, null, "", "");
|
new LastComposedWord(null, null, null, "", "");
|
||||||
|
|
||||||
|
// Warning: this is using the passed objects as is and fully expects them to be
|
||||||
|
// immutable. Do not fiddle with their contents after you passed them to this constructor.
|
||||||
public LastComposedWord(final ArrayList<int[]> codes, final int[] xCoordinates,
|
public LastComposedWord(final ArrayList<int[]> codes, final int[] xCoordinates,
|
||||||
final int[] yCoordinates, final String typedWord, final String autoCorrection) {
|
final int[] yCoordinates, final String typedWord, final String autoCorrection) {
|
||||||
mCodes = codes;
|
mCodes = codes;
|
||||||
|
|
|
@ -2201,9 +2201,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// new composing text.
|
// new composing text.
|
||||||
final int restartLength = mWordComposer.size();
|
final int restartLength = mWordComposer.size();
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
final String wordBeforeCursor =
|
final String wordBeforeCursor = ic.getTextBeforeCursor(restartLength, 0).toString();
|
||||||
ic.getTextBeforeCursor(restartLength + 1, 0).subSequence(0, restartLength)
|
|
||||||
.toString();
|
|
||||||
if (!TextUtils.equals(mWordComposer.getTypedWord(), wordBeforeCursor)) {
|
if (!TextUtils.equals(mWordComposer.getTypedWord(), wordBeforeCursor)) {
|
||||||
throw new RuntimeException("restartSuggestionsOnManuallyPickedTypedWord "
|
throw new RuntimeException("restartSuggestionsOnManuallyPickedTypedWord "
|
||||||
+ "check failed: we thought we were reverting \""
|
+ "check failed: we thought we were reverting \""
|
||||||
|
@ -2212,8 +2210,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
+ wordBeforeCursor + "\"");
|
+ wordBeforeCursor + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Warning: this +1 takes into account the extra space added by the manual pick process.
|
ic.deleteSurroundingText(restartLength, 0);
|
||||||
ic.deleteSurroundingText(restartLength + 1, 0);
|
|
||||||
ic.setComposingText(mWordComposer.getTypedWord(), 1);
|
ic.setComposingText(mWordComposer.getTypedWord(), 1);
|
||||||
mHandler.cancelUpdateBigramPredictions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
|
|
|
@ -310,13 +310,18 @@ public class WordComposer {
|
||||||
// LastComposedWord#didAutoCorrectToAnotherWord with #equals(). It would be marginally
|
// LastComposedWord#didAutoCorrectToAnotherWord with #equals(). It would be marginally
|
||||||
// cleaner to do it here, but it would be slower (since we would #equals() for each commit,
|
// cleaner to do it here, but it would be slower (since we would #equals() for each commit,
|
||||||
// instead of only on cancel), and ultimately we want to figure it out even earlier anyway.
|
// instead of only on cancel), and ultimately we want to figure it out even earlier anyway.
|
||||||
final LastComposedWord lastComposedWord = new LastComposedWord(mCodes,
|
final ArrayList<int[]> codes = mCodes;
|
||||||
mXCoordinates, mYCoordinates, mTypedWord.toString(),
|
final int[] xCoordinates = mXCoordinates;
|
||||||
|
final int[] yCoordinates = mYCoordinates;
|
||||||
|
mCodes = new ArrayList<int[]>(N);
|
||||||
|
mXCoordinates = new int[N];
|
||||||
|
mYCoordinates = new int[N];
|
||||||
|
final LastComposedWord lastComposedWord = new LastComposedWord(codes,
|
||||||
|
xCoordinates, yCoordinates, mTypedWord.toString(),
|
||||||
null == mAutoCorrection ? null : mAutoCorrection.toString());
|
null == mAutoCorrection ? null : mAutoCorrection.toString());
|
||||||
if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD) {
|
if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD) {
|
||||||
lastComposedWord.deactivate();
|
lastComposedWord.deactivate();
|
||||||
}
|
}
|
||||||
mCodes.clear();
|
|
||||||
mTypedWord.setLength(0);
|
mTypedWord.setLength(0);
|
||||||
mAutoCorrection = null;
|
mAutoCorrection = null;
|
||||||
return lastComposedWord;
|
return lastComposedWord;
|
||||||
|
|
Loading…
Reference in a new issue