aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-09-17 06:45:48 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-17 06:45:48 -0700
commitef518bfd1cfba18e76998b1ad51fb54eaeaec6b1 (patch)
treeaf830f63dbb5cb5c672189c90fd53e08bfd0a701 /java/src
parent97f53a9fe75d4a378882056f199e7eb24d5ca741 (diff)
parent9b78241dff6b785408ae19512f6875e63771b349 (diff)
downloadlatinime-ef518bfd1cfba18e76998b1ad51fb54eaeaec6b1.tar.gz
latinime-ef518bfd1cfba18e76998b1ad51fb54eaeaec6b1.tar.xz
latinime-ef518bfd1cfba18e76998b1ad51fb54eaeaec6b1.zip
am 9b78241d: Merge "Improve trailing quotes processing"
* commit '9b78241dff6b785408ae19512f6875e63771b349': Improve trailing quotes processing
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 7815f4d41..1684d47b5 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -460,7 +460,7 @@ public final class Suggest {
private static final SuggestedWordInfoComparator sSuggestedWordInfoComparator =
new SuggestedWordInfoComparator();
- private static SuggestedWordInfo getTransformedSuggestedWordInfo(
+ /* package for test */ static SuggestedWordInfo getTransformedSuggestedWordInfo(
final SuggestedWordInfo wordInfo, final Locale locale, final boolean isAllUpperCase,
final boolean isFirstCharCapitalized, final int trailingSingleQuotesCount) {
final StringBuilder sb = new StringBuilder(wordInfo.mWord.length());
@@ -471,7 +471,12 @@ public final class Suggest {
} else {
sb.append(wordInfo.mWord);
}
- for (int i = trailingSingleQuotesCount - 1; i >= 0; --i) {
+ // Appending quotes is here to help people quote words. However, it's not helpful
+ // when they type words with quotes toward the end like "it's" or "didn't", where
+ // it's more likely the user missed the last character (or didn't type it yet).
+ final int quotesToAppend = trailingSingleQuotesCount
+ - (-1 == wordInfo.mWord.indexOf(Constants.CODE_SINGLE_QUOTE) ? 0 : 1);
+ for (int i = quotesToAppend - 1; i >= 0; --i) {
sb.appendCodePoint(Constants.CODE_SINGLE_QUOTE);
}
return new SuggestedWordInfo(sb.toString(), wordInfo.mScore, wordInfo.mKind,