mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix many small nits.
...the interaction of which results in a very bad bug. Bug: 11648854 Change-Id: I774489e384388f187e72b9ac091ab387c5e1a79a
This commit is contained in:
parent
a2a1096406
commit
5a0bc6ac69
@ -908,6 +908,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||||||
false /* shouldFinishComposition */)) {
|
false /* shouldFinishComposition */)) {
|
||||||
// We try resetting the caches up to 5 times before giving up.
|
// We try resetting the caches up to 5 times before giving up.
|
||||||
mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */);
|
mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */);
|
||||||
|
// mLastSelection{Start,End} are reset later in this method, don't need to do it here
|
||||||
canReachInputConnection = false;
|
canReachInputConnection = false;
|
||||||
} else {
|
} else {
|
||||||
if (isDifferentTextField) {
|
if (isDifferentTextField) {
|
||||||
@ -987,10 +988,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||||||
if (textLength > mLastSelectionStart
|
if (textLength > mLastSelectionStart
|
||||||
|| (textLength < Constants.EDITOR_CONTENTS_CACHE_SIZE
|
|| (textLength < Constants.EDITOR_CONTENTS_CACHE_SIZE
|
||||||
&& mLastSelectionStart < Constants.EDITOR_CONTENTS_CACHE_SIZE)) {
|
&& mLastSelectionStart < Constants.EDITOR_CONTENTS_CACHE_SIZE)) {
|
||||||
|
// It should not be possible to have only one of those variables be
|
||||||
|
// NOT_A_CURSOR_POSITION, so if they are equal, either the selection is zero-sized
|
||||||
|
// (simple cursor, no selection) or there is no cursor/we don't know its pos
|
||||||
|
final boolean wasEqual = mLastSelectionStart == mLastSelectionEnd;
|
||||||
mLastSelectionStart = textLength;
|
mLastSelectionStart = textLength;
|
||||||
// We can't figure out the value of mLastSelectionEnd :(
|
// We can't figure out the value of mLastSelectionEnd :(
|
||||||
// But at least if it's smaller than mLastSelectionStart something is wrong
|
// But at least if it's smaller than mLastSelectionStart something is wrong,
|
||||||
if (mLastSelectionStart > mLastSelectionEnd) {
|
// and if they used to be equal we also don't want to make it look like there is a
|
||||||
|
// selection.
|
||||||
|
if (wasEqual || mLastSelectionStart > mLastSelectionEnd) {
|
||||||
mLastSelectionEnd = mLastSelectionStart;
|
mLastSelectionEnd = mLastSelectionStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public final class RichInputConnection {
|
|||||||
* cursor may end up after all the keyboard-triggered updates have passed. We keep this to
|
* cursor may end up after all the keyboard-triggered updates have passed. We keep this to
|
||||||
* compare it to the actual cursor position to guess whether the move was caused by a
|
* compare it to the actual cursor position to guess whether the move was caused by a
|
||||||
* keyboard command or not.
|
* keyboard command or not.
|
||||||
* It's not really the cursor position: the cursor may not be there yet, and it's also expected
|
* It's not really the cursor position: the cursor may not be there yet, and it's also expected
|
||||||
* there be cases where it never actually comes to be there.
|
* there be cases where it never actually comes to be there.
|
||||||
*/
|
*/
|
||||||
private int mExpectedCursorPosition = INVALID_CURSOR_POSITION; // in chars, not code points
|
private int mExpectedCursorPosition = INVALID_CURSOR_POSITION; // in chars, not code points
|
||||||
@ -292,7 +292,11 @@ public final class RichInputConnection {
|
|||||||
mCommittedTextBeforeComposingText.length() + mComposingText.length();
|
mCommittedTextBeforeComposingText.length() + mComposingText.length();
|
||||||
// If we have enough characters to satisfy the request, or if we have all characters in
|
// If we have enough characters to satisfy the request, or if we have all characters in
|
||||||
// the text field, then we can return the cached version right away.
|
// the text field, then we can return the cached version right away.
|
||||||
if (cachedLength >= n || cachedLength >= mExpectedCursorPosition) {
|
// However, if we don't have an expected cursor position, then we should always
|
||||||
|
// go fetch the cache again (as it happens, INVALID_CURSOR_POSITION < 0, so we need to
|
||||||
|
// test for this explicitly)
|
||||||
|
if (INVALID_CURSOR_POSITION != mExpectedCursorPosition
|
||||||
|
&& (cachedLength >= n || cachedLength >= mExpectedCursorPosition)) {
|
||||||
final StringBuilder s = new StringBuilder(mCommittedTextBeforeComposingText);
|
final StringBuilder s = new StringBuilder(mCommittedTextBeforeComposingText);
|
||||||
// We call #toString() here to create a temporary object.
|
// We call #toString() here to create a temporary object.
|
||||||
// In some situations, this method is called on a worker thread, and it's possible
|
// In some situations, this method is called on a worker thread, and it's possible
|
||||||
|
Loading…
x
Reference in New Issue
Block a user