limited recomposing to capture words consisting of letters only, and ignore special chars
This commit is contained in:
parent
40b48bba52
commit
910cc2a46a
2 changed files with 12 additions and 5 deletions
|
|
@ -135,7 +135,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.getBackspaceRecomposing() && !hold && suggestionOps.isEmpty()) {
|
if (settings.getBackspaceRecomposing() && !hold && suggestionOps.isEmpty()) {
|
||||||
final String previousWord = textField.getWordBeforeCursor();
|
final String previousWord = textField.getWordBeforeCursor(mLanguage);
|
||||||
if (mInputMode.recompose(previousWord) && textField.recompose(previousWord)) {
|
if (mInputMode.recompose(previousWord) && textField.recompose(previousWord)) {
|
||||||
getSuggestions();
|
getSuggestions();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ public class TextField extends InputField {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NonNull public String getWordBeforeCursor() {
|
@NonNull public String getWordBeforeCursor(Language language) {
|
||||||
if (getTextAfterCursor(1).startsWithWord()) {
|
if (getTextAfterCursor(1).startsWithWord()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
@ -115,10 +115,17 @@ public class TextField extends InputField {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastSpace = Math.max(before.lastIndexOf(' ') + 1, 0);
|
for (int i = before.length() - 1; i >= 0; i--) {
|
||||||
int length = Math.max(before.length(), lastSpace);
|
char currentLetter = before.charAt(i);
|
||||||
|
if (
|
||||||
|
!Character.isAlphabetic(currentLetter)
|
||||||
|
&& !(currentLetter == '\'' && (LanguageKind.isHebrew(language) || LanguageKind.isUkrainian(language)))
|
||||||
|
) {
|
||||||
|
return before.substring(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return before.substring(lastSpace, length);
|
return before;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue