mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 22:29:10 +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;
|
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):
|
// what is sometimes happening (depending on app, or maybe input field attributes):
|
||||||
// we just pressed delete, and getTextBeforeCursor gets the correct text,
|
// we just pressed delete, and getTextBeforeCursor gets the correct text,
|
||||||
// but getTextBeforeCursorAndDetectLaggyConnection returns the old word, before the deletion (not sure why)
|
// 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
|
// interestingly, getTextBeforeCursor seems to only get the correct text because it uses
|
||||||
// mCommittedTextBeforeComposingText where the text is cached
|
// mCommittedTextBeforeComposingText where the text is cached
|
||||||
// (this check is really annoyingly long for the simple thing to be done)
|
// what could be actually going on? we probably need to fetch the text because we want updated styles if any
|
||||||
if (before.length() > 0 && after.length() == 0) {
|
|
||||||
|
// 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());
|
final int lastBeforeCodePoint = Character.codePointBefore(before, before.length());
|
||||||
if (!isPartOfCompositionForScript(lastBeforeCodePoint, spacingAndPunctuations, scriptId)) {
|
// check whether before ends with the same codepoint as getTextBeforeCursor
|
||||||
// before ends with separator or similar -> check whether text before cursor ends with the same codepoint
|
|
||||||
int lastBeforeLength = Character.charCount(lastBeforeCodePoint);
|
int lastBeforeLength = Character.charCount(lastBeforeCodePoint);
|
||||||
CharSequence codePointBeforeCursor = getTextBeforeCursor(lastBeforeLength, 0);
|
CharSequence codePointBeforeCursor = getTextBeforeCursor(lastBeforeLength, 0);
|
||||||
if (codePointBeforeCursor.length() != 0 && Character.codePointAt(codePointBeforeCursor, 0) != lastBeforeCodePoint) {
|
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);
|
final CharSequence beforeCursor = getTextBeforeCursor(beforeWithoutLast.length(), 0);
|
||||||
if (beforeCursor.length() == beforeWithoutLast.length()) {
|
if (beforeCursor.length() == beforeWithoutLast.length()) {
|
||||||
boolean same = true;
|
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++) {
|
for (int i = 0; i < beforeCursor.length(); i++) {
|
||||||
if (beforeCursor.charAt(i) != beforeWithoutLast.charAt(i)) {
|
if (beforeCursor.charAt(i) != beforeWithoutLast.charAt(i)) {
|
||||||
same = false;
|
same = false;
|
||||||
|
@ -751,7 +756,6 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Going backward, find the first breaking point (separator)
|
// Going backward, find the first breaking point (separator)
|
||||||
int startIndexInBefore = before.length();
|
int startIndexInBefore = before.length();
|
||||||
|
|
Loading…
Add table
Reference in a new issue