improve emoji detection when deleting

still has issues with hand + skin tone emojis
This commit is contained in:
Helium314 2024-06-12 23:54:23 +02:00
parent d91350524a
commit 6a34f2c832
3 changed files with 10 additions and 6 deletions

View file

@ -1072,10 +1072,12 @@ public final class RichInputConnection implements PrivateCommandPerformer {
public int getCharCountToDeleteBeforeCursor() {
final int lastCodePoint = getCodePointBeforeCursor();
if (!Character.isSupplementaryCodePoint(lastCodePoint)) return 1;
if (!StringUtils.mightBeEmoji(lastCodePoint)) return 2;
final String text = mCommittedTextBeforeComposingText.toString() + mComposingText;
return StringUtilsKt.getFullEmojiAtEnd(text).length();
if (StringUtils.mightBeEmoji(lastCodePoint)) {
final String text = mCommittedTextBeforeComposingText.toString() + mComposingText;
final int emojiLength = StringUtilsKt.getFullEmojiAtEnd(text).length();
if (emojiLength > 0) return emojiLength;
}
return Character.isSupplementaryCodePoint(lastCodePoint) ? 2 : 1;
}
public boolean hasLetterBeforeLastSpaceBeforeCursor() {