1
0
Fork 0

fixed confusing Backspace behavior when deleting selected or composed text

This commit is contained in:
sspanak 2025-04-24 11:51:33 +03:00 committed by Dimo Karaivanov
parent e4b2f97603
commit 4f3f16c39e
2 changed files with 5 additions and 2 deletions

View file

@ -127,7 +127,8 @@ public abstract class TypingHandler extends KeyPadHandler {
return true; return true;
} }
if (repeat == 0 && mInputMode.onBackspace()) { boolean noTextSelection = textSelection.isEmpty(); // loading words after deleting selected text is confusing
if (repeat == 0 && mInputMode.onBackspace() && noTextSelection) {
getSuggestions(null); getSuggestions(null);
} else { } else {
suggestionOps.commitCurrent(false, true); suggestionOps.commitCurrent(false, true);
@ -135,7 +136,7 @@ public abstract class TypingHandler extends KeyPadHandler {
deleteText(settings.getBackspaceAcceleration() && repeat > 0); deleteText(settings.getBackspaceAcceleration() && repeat > 0);
} }
if (settings.getBackspaceRecomposing() && repeat == 0 && suggestionOps.isEmpty() && !DictionaryLoader.getInstance(this).isRunning()) { if (settings.getBackspaceRecomposing() && repeat == 0 && noTextSelection && suggestionOps.isEmpty() && !DictionaryLoader.getInstance(this).isRunning()) {
final String previousWord = mInputMode.recompose(); final String previousWord = mInputMode.recompose();
if (textField.recompose(previousWord)) { if (textField.recompose(previousWord)) {
getSuggestions(previousWord); getSuggestions(previousWord);

View file

@ -138,6 +138,7 @@ public class TextField extends InputField {
} }
if (isNonText) { if (isNonText) {
composingText = composingText.length() > 1 ? composingText.subSequence(0, composingText.length() - 1) : "";
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL); sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
return; return;
} }
@ -150,6 +151,7 @@ public class TextField extends InputField {
} }
} }
composingText = composingText.length() > numberOfChars ? composingText.subSequence(0, composingText.length() - numberOfChars) : "";
connection.deleteSurroundingText(numberOfChars, 0); connection.deleteSurroundingText(numberOfChars, 0);
} }