1
0
Fork 0

fixed fast-delete deleting too much text in languages without spaces, when there is composing text

This commit is contained in:
sspanak 2025-04-22 18:05:13 +03:00 committed by Dimo Karaivanov
parent 77bbae05d1
commit f594a6f258
2 changed files with 13 additions and 4 deletions

View file

@ -245,12 +245,15 @@ public abstract class TypingHandler extends KeyPadHandler {
private void deleteText(boolean deleteMany) {
int charsToDelete = 1;
if (deleteMany) {
charsToDelete = Math.max(textField.getPaddedWordBeforeCursorLength(), 1);
} else if (!textSelection.isEmpty()) {
if (!textSelection.isEmpty()) {
charsToDelete = textSelection.length();
textSelection.clear(false);
} else if (deleteMany) {
charsToDelete = textField.getComposingText().length();
charsToDelete = charsToDelete > 0 ? charsToDelete : Math.max(textField.getPaddedWordBeforeCursorLength(), 1);
}
textField.deleteChars(charsToDelete);
}

View file

@ -20,7 +20,7 @@ import io.github.sspanak.tt9.util.Logger;
import io.github.sspanak.tt9.util.Text;
public class TextField extends InputField {
private CharSequence composingText = "";
@NonNull private CharSequence composingText = "";
private final boolean isComposingSupported;
private final boolean isNonText;
@ -231,6 +231,12 @@ public class TextField extends InputField {
}
@NonNull
public String getComposingText() {
return composingText.toString();
}
/**
* setComposingText
* A fail-safe setter for composing text, which ignores NULL input.