mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 14:19:08 +00:00
further improve fix in ce0bf06545
This commit is contained in:
parent
78cccee9bb
commit
9713c4a25a
1 changed files with 27 additions and 23 deletions
|
@ -718,17 +718,22 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
|||
return null;
|
||||
}
|
||||
|
||||
// issue:
|
||||
// type 2 words and space, press delete twice -> remaining word and space before are selected
|
||||
// now on next key press, the space before the word is removed
|
||||
// or complete a word by choosing a suggestion than press backspace -> same thing
|
||||
// what is sometimes happening (depending on app, or maybe input field attributes):
|
||||
// we just pressed delete, and getTextBeforeCursor gets the correct text,
|
||||
// but getTextBeforeCursorAndDetectLaggyConnection returns the old word, before the deletion (not sure why)
|
||||
// -> detect this difference, and try to fix it
|
||||
// -> we try to detect this difference, and then try to fix it
|
||||
// interestingly, getTextBeforeCursor seems to only get the correct text because it uses
|
||||
// mCommittedTextBeforeComposingText where the text is cached
|
||||
// (this check is really annoyingly long for the simple thing to be done)
|
||||
if (before.length() > 0 && after.length() == 0) {
|
||||
// what could be actually going on? we probably need to fetch the text because we want updated styles if any
|
||||
|
||||
// we need text before, and text after is always empty or a separator or similar
|
||||
if (before.length() > 0 && (after.length() == 0 || !isPartOfCompositionForScript(Character.codePointBefore(after, 0), spacingAndPunctuations, scriptId))) {
|
||||
final int lastBeforeCodePoint = Character.codePointBefore(before, before.length());
|
||||
if (!isPartOfCompositionForScript(lastBeforeCodePoint, spacingAndPunctuations, scriptId)) {
|
||||
// before ends with separator or similar -> check whether text before cursor ends with the same codepoint
|
||||
// check whether before ends with the same codepoint as getTextBeforeCursor
|
||||
int lastBeforeLength = Character.charCount(lastBeforeCodePoint);
|
||||
CharSequence codePointBeforeCursor = getTextBeforeCursor(lastBeforeLength, 0);
|
||||
if (codePointBeforeCursor.length() != 0 && Character.codePointAt(codePointBeforeCursor, 0) != lastBeforeCodePoint) {
|
||||
|
@ -738,7 +743,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
|||
final CharSequence beforeCursor = getTextBeforeCursor(beforeWithoutLast.length(), 0);
|
||||
if (beforeCursor.length() == beforeWithoutLast.length()) {
|
||||
boolean same = true;
|
||||
// CharSequence has undefined equals
|
||||
// CharSequence has undefined equals, so we need to compare characters
|
||||
for (int i = 0; i < beforeCursor.length(); i++) {
|
||||
if (beforeCursor.charAt(i) != beforeWithoutLast.charAt(i)) {
|
||||
same = false;
|
||||
|
@ -751,7 +756,6 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Going backward, find the first breaking point (separator)
|
||||
int startIndexInBefore = before.length();
|
||||
|
|
Loading…
Add table
Reference in a new issue