am c8094c46: Merge "[SD6] Inline a constant and remove logic become useless"
* commit 'c8094c463b7ee41feef49bb331eb6509b30d751f': [SD6] Inline a constant and remove logic become uselessmain
commit
f6974abd85
|
@ -626,7 +626,6 @@ public final class RichInputConnection {
|
||||||
* @return a range containing the text surrounding the cursor
|
* @return a range containing the text surrounding the cursor
|
||||||
*/
|
*/
|
||||||
public TextRange getWordRangeAtCursor(final int[] sortedSeparators) {
|
public TextRange getWordRangeAtCursor(final int[] sortedSeparators) {
|
||||||
final int additionalPrecedingWordsCount = 0;
|
|
||||||
mIC = mParent.getCurrentInputConnection();
|
mIC = mParent.getCurrentInputConnection();
|
||||||
if (mIC == null) {
|
if (mIC == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -639,30 +638,18 @@ public final class RichInputConnection {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Going backward, alternate skipping non-separators and separators until enough words
|
// Going backward, find the first breaking point (separator)
|
||||||
// have been read.
|
|
||||||
int count = additionalPrecedingWordsCount;
|
|
||||||
int startIndexInBefore = before.length();
|
int startIndexInBefore = before.length();
|
||||||
boolean isStoppingAtWhitespace = true; // toggles to indicate what to stop at
|
|
||||||
while (true) { // see comments below for why this is guaranteed to halt
|
|
||||||
while (startIndexInBefore > 0) {
|
while (startIndexInBefore > 0) {
|
||||||
final int codePoint = Character.codePointBefore(before, startIndexInBefore);
|
final int codePoint = Character.codePointBefore(before, startIndexInBefore);
|
||||||
if (isStoppingAtWhitespace == isSeparator(codePoint, sortedSeparators)) {
|
if (isSeparator(codePoint, sortedSeparators)) {
|
||||||
break; // inner loop
|
break;
|
||||||
}
|
}
|
||||||
--startIndexInBefore;
|
--startIndexInBefore;
|
||||||
if (Character.isSupplementaryCodePoint(codePoint)) {
|
if (Character.isSupplementaryCodePoint(codePoint)) {
|
||||||
--startIndexInBefore;
|
--startIndexInBefore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// isStoppingAtWhitespace is true every other time through the loop,
|
|
||||||
// so additionalPrecedingWordsCount is guaranteed to become < 0, which
|
|
||||||
// guarantees outer loop termination
|
|
||||||
if (isStoppingAtWhitespace && (--count < 0)) {
|
|
||||||
break; // outer loop
|
|
||||||
}
|
|
||||||
isStoppingAtWhitespace = !isStoppingAtWhitespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find last word separator after the cursor
|
// Find last word separator after the cursor
|
||||||
int endIndexInAfter = -1;
|
int endIndexInAfter = -1;
|
||||||
|
|
Loading…
Reference in New Issue