diff options
author | 2012-10-04 05:57:34 -0700 | |
---|---|---|
committer | 2012-10-04 05:57:34 -0700 | |
commit | bf6c8bd84c273ad04371d0fa8a1a0aac0da91798 (patch) | |
tree | 0710ccc18e7f0e69362d30e18fe82210eb201d2d /java/src | |
parent | 62038ee1c4bda81fa8a2ceaf26515fefe67551f3 (diff) | |
parent | 3f7fe82992a4f62544ac3069903e73c37ca87498 (diff) | |
download | latinime-bf6c8bd84c273ad04371d0fa8a1a0aac0da91798.tar.gz latinime-bf6c8bd84c273ad04371d0fa8a1a0aac0da91798.tar.xz latinime-bf6c8bd84c273ad04371d0fa8a1a0aac0da91798.zip |
am 3f7fe829: Merge "Always consider a new line the start of a sentence" into jb-mr1-dev
* commit '3f7fe82992a4f62544ac3069903e73c37ca87498':
Always consider a new line the start of a sentence
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/StringUtils.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java index 7b65b7343..df7709892 100644 --- a/java/src/com/android/inputmethod/latin/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/StringUtils.java @@ -250,15 +250,19 @@ public final class StringUtils { // Step 3 : Search for the start of a paragraph. From the starting point computed in step 2, // we go back over any space or tab char sitting there. We find the start of a paragraph - // if the first char that's not a space or tab is a start of line (as in, either \n or - // start of text). + // if the first char that's not a space or tab is a start of line (as in \n, start of text, + // or some other similar characters). int j = i; + char prevChar = Keyboard.CODE_SPACE; if (hasSpaceBefore) --j; - while (j > 0 && Character.isWhitespace(cs.charAt(j - 1))) { + while (j > 0) { + prevChar = cs.charAt(j - 1); + if (!Character.isSpaceChar(prevChar) && prevChar != Keyboard.CODE_TAB) break; j--; } - if (j == 0) { - // There is only whitespace between the start of the text and the cursor. Both + if (j <= 0 || Character.isWhitespace(prevChar)) { + // There are only spacing chars between the start of the paragraph and the cursor, + // defined as a isWhitespace() char that is neither a isSpaceChar() nor a tab. Both // MODE_WORDS and MODE_SENTENCES should be active. return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS | TextUtils.CAP_MODE_SENTENCES) & reqModes; |