aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-01-27 10:01:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-01-27 10:01:17 +0000
commit6d1c8b2c3f78969866db7f718e7e8d2be240f674 (patch)
tree5ded1bf0989dc4586bb173ef7fa7a3c0fda7ec31 /java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
parentb084da2ae6622488779ddb3a66081610bfe96a66 (diff)
parentc7ef305bbc119b820fd619d3ed205198d4f98c3f (diff)
downloadlatinime-6d1c8b2c3f78969866db7f718e7e8d2be240f674.tar.gz
latinime-6d1c8b2c3f78969866db7f718e7e8d2be240f674.tar.xz
latinime-6d1c8b2c3f78969866db7f718e7e8d2be240f674.zip
Merge "Try to figure out whether d.quotes open or close."
Diffstat (limited to 'java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index d4f7f0ecd..300c7c9bf 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -670,8 +670,21 @@ public final class InputLogic {
final boolean swapWeakSpace = maybeStripSpace(settingsValues, codePoint, spaceState,
isFromSuggestionStrip);
- if (SpaceState.PHANTOM == spaceState &&
- settingsValues.isUsuallyPrecededBySpace(codePoint)) {
+ final boolean isInsideDoubleQuoteOrAfterDigit = Constants.CODE_DOUBLE_QUOTE == codePoint
+ && mConnection.isInsideDoubleQuoteOrAfterDigit();
+
+ final boolean needsPrecedingSpace;
+ if (SpaceState.PHANTOM != spaceState) {
+ needsPrecedingSpace = false;
+ } else if (Constants.CODE_DOUBLE_QUOTE == codePoint) {
+ // Double quotes behave like they are usually preceded by space iff we are
+ // not inside a double quote or after a digit.
+ needsPrecedingSpace = !isInsideDoubleQuoteOrAfterDigit;
+ } else {
+ needsPrecedingSpace = settingsValues.isUsuallyPrecededBySpace(codePoint);
+ }
+
+ if (needsPrecedingSpace) {
promotePhantomSpace(settingsValues);
}
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
@@ -698,14 +711,17 @@ public final class InputLogic {
if (swapWeakSpace) {
swapSwapperAndSpace(keyboardSwitcher);
mSpaceState = SpaceState.SWAP_PUNCTUATION;
- } else if (SpaceState.PHANTOM == spaceState
- && settingsValues.isUsuallyFollowedBySpace(codePoint)) {
+ } else if ((SpaceState.PHANTOM == spaceState
+ && settingsValues.isUsuallyFollowedBySpace(codePoint))
+ || (Constants.CODE_DOUBLE_QUOTE == codePoint
+ && isInsideDoubleQuoteOrAfterDigit)) {
// If we are in phantom space state, and the user presses a separator, we want to
// stay in phantom space state so that the next keypress has a chance to add the
// space. For example, if I type "Good dat", pick "day" from the suggestion strip
// then insert a comma and go on to typing the next word, I want the space to be
// inserted automatically before the next word, the same way it is when I don't
- // input the comma.
+ // input the comma. A double quote behaves like it's usually followed by space if
+ // we're inside a double quote.
// The case is a little different if the separator is a space stripper. Such a
// separator does not normally need a space on the right (that's the difference
// between swappers and strippers), so we should not stay in phantom space state if