regression: fixed incorrect recomposing in Japanese and Chinese
This commit is contained in:
parent
f594a6f258
commit
86a3274436
1 changed files with 10 additions and 7 deletions
|
|
@ -99,7 +99,7 @@ public class ModeIdeograms extends ModeWords {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAcceptSuggestion(@NonNull String currentWord, boolean preserveWords) {
|
public void onAcceptSuggestion(@NonNull String currentWord, boolean preserveWords) {
|
||||||
Text text = new Text(currentWord);
|
final Text text = new Text(currentWord);
|
||||||
if (text.isEmpty() || text.startsWithWhitespace() || text.isNumeric()) {
|
if (text.isEmpty() || text.startsWithWhitespace() || text.isNumeric()) {
|
||||||
reset();
|
reset();
|
||||||
Logger.i(LOG_TAG, "Current word is empty or numeric. Nothing to accept.");
|
Logger.i(LOG_TAG, "Current word is empty or numeric. Nothing to accept.");
|
||||||
|
|
@ -113,21 +113,24 @@ public class ModeIdeograms extends ModeWords {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int initialLength = digitSequence.length();
|
||||||
|
final boolean lastDigitBelongsToNewWord = preserveWords && initialLength >= 2;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!digitSequence.equals(SPECIAL_CHAR_SEQUENCE) && !digitSequence.equals(PUNCTUATION_SEQUENCE)) {
|
if (!digitSequence.equals(SPECIAL_CHAR_SEQUENCE) && !digitSequence.equals(PUNCTUATION_SEQUENCE)) {
|
||||||
((IdeogramPredictions) predictions).onAcceptIdeogram(currentWord);
|
|
||||||
lastAcceptedSequence = digitSequence;
|
|
||||||
lastAcceptedWord = currentWord;
|
lastAcceptedWord = currentWord;
|
||||||
|
lastAcceptedSequence = lastDigitBelongsToNewWord ? digitSequence.substring(0, initialLength - 1) : digitSequence;
|
||||||
|
|
||||||
|
predictions.setDigitSequence(lastAcceptedSequence);
|
||||||
|
((IdeogramPredictions) predictions).onAcceptIdeogram(currentWord);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
lastAcceptedSequence = lastAcceptedWord = "";
|
||||||
Logger.e(LOG_TAG, "Failed incrementing priority of word: '" + currentWord + "'. " + e.getMessage());
|
Logger.e(LOG_TAG, "Failed incrementing priority of word: '" + currentWord + "'. " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = digitSequence.length();
|
if (lastDigitBelongsToNewWord) {
|
||||||
if (preserveWords && len >= 2) {
|
digitSequence = digitSequence.substring(initialLength - 1);
|
||||||
digitSequence = digitSequence.substring(len - 1);
|
|
||||||
loadSuggestions("");
|
loadSuggestions("");
|
||||||
} else {
|
} else {
|
||||||
reset();
|
reset();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue