Accelerated backspace measures the wrong code point and can split an emoji
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java 第2019–2026行附近的程式碼,從加速退格邏輯及其如何讀取游標前的碼點開始檢查。分別檢查一般字元後接表情符號,以及表情符號後接一般字元時的刪除長度;完成的標準是第二次刪除使用重新讀取的碼點,且不會拆開表情符號或多刪一個一般字元。
由索引模型根據 Issue 內容生成。
描述
Summary
In InputLogic.handleBackspaceEvent, the accelerated (held-backspace) second deletion measures its length from the first code point instead of the one it is actually about to delete. When the second character back is a multi-code-point emoji, this deletes the wrong number of chars and can split the emoji, leaving an orphaned surrogate or a stray variation selector / ZWJ.
Present at tag v4.1.2 (f0ff166ae).
Location
app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java, around lines 2019–2026:
final int codePointBeforeCursorToDeleteAgain = mConnection.getCodePointBeforeCursor();
if (codePointBeforeCursorToDeleteAgain != Constants.NOT_A_CODE) {
final int lengthToDeleteAgain = codePointBeforeCursor > 0xFE00 // <-- first code point
|| StringUtils.mightBeEmoji(codePointBeforeCursor) // <-- first code point
? mConnection.getCharCountToDeleteBeforeCursor()
: 1;
mConnection.deleteTextBeforeCursor(lengthToDeleteAgain);
totalDeletedLength += lengthToDeleteAgain;
}
The guard correctly re-reads the cursor into codePointBeforeCursorToDeleteAgain, but the ternary that decides the delete length still tests codePointBeforeCursor — the value from before the first deletion.
Consequences
Both directions are wrong:
- First char plain, second an emoji → the branch evaluates
false, solengthToDeleteAgainis1. A singlecharis removed from a multi-charemoji, splitting it. - First char an emoji, second plain → the branch evaluates
true, sogetCharCountToDeleteBeforeCursor()is used against a plain character and may remove more than intended.
Only reachable once mDeleteCount > Constants.DELETE_ACCELERATE_AT, i.e. while holding backspace, which is probably why it has gone unnoticed.
Suggested fix
Use the re-read value in the condition, so it describes the character actually being deleted:
final int lengthToDeleteAgain = codePointBeforeCursorToDeleteAgain > 0xFE00
|| StringUtils.mightBeEmoji(codePointBeforeCursorToDeleteAgain)
? mConnection.getCharCountToDeleteBeforeCursor()
: 1;
Notes
Found while merging v4.1.2 into a downstream fork. This almost certainly predates LeanType — the surrounding accelerated-delete code comes from the HeliBoard/AOSP lineage — so it may be worth forwarding to Helium314/HeliBoard as well.
I have no reproduction on a physical device; this is from reading the code, so please sanity-check the emoji-splitting claim against real input before acting on it.
- 主要語言
- Kotlin
- 星號
- 1k
- 分支
- 59
- 平均合併
- 13 小時 21 分鐘
- 30 天內合併 PR
- 48
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
LeanBitLab/LeanType 的其他 Issue
-
Voice input fails in browser address bars due to incorrect password field detection (v4.2.9, follow-up to #516)可能已有人在做 @LeanBitLab 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 76/100
LeanBitLab/LeanType#713 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
bug
難度 3/5 1-2 天 新手友好度 54/100
LeanBitLab/LeanType#717 ·
維護者通常 1 天內回覆
-
Crush Report可能已有人在做 @LeanBitLab 今天認領。 未關閉
難度 3/5 1-2 天 新手友好度 20/100
LeanBitLab/LeanType#715 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Text Expander/cursor-handling bug可能已有人在做 @LeanBitLab 於 2 天前認領。 未關閉bug
難度 3/5 1-2 天 新手友好度 62/100
LeanBitLab/LeanType#703 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
enhancement
難度 3/5 1-2 天 新手友好度 45/100
LeanBitLab/LeanType#699 ·
維護者通常 1 天內回覆
查看 LeanBitLab/LeanType 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
mcnaveen/health-connect-webhook#110 ·
維護者通常 1 天內回覆
-
Delete all above未關閉enhancement
難度 2/5 1-3 小時 新手友好度 68/100
mjaakko/NeoStumbler#1307 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
tanujnotes/Olauncher#770 ·
-
難度 2/5 1-3 小時 新手友好度 66/100
-
submit-adaption submit-adaption-pre
難度 1/5 1 小時以內 新手友好度 76/100
BetterAndroid/android-notification-icon-project#795 · 1 則留言 ·
維護者通常 1 天內回覆