Accelerated backspace measures the wrong code point and can split an emoji
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 65/100
Línea de trabajo
Lee app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java alrededor de las líneas 2019–2026, empezando por la lógica de retroceso acelerado y cómo lee el punto de código anterior al cursor. Comprueba la longitud del borrado tanto para un carácter normal seguido de un emoji como para un emoji seguido de un carácter normal; se considera terminado cuando el segundo borrado usa el punto de código vuelto a leer y no divide un emoji ni borra de más un carácter normal.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Kotlin
- Estrellas
- 1k
- Forks
- 59
- Merge medio
- 13 h 21 min
- PR fusionados (30 d)
- 48
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de LeanBitLab/LeanType
-
Voice input fails in browser address bars due to incorrect password field detection (v4.2.9, follow-up to #516)Posiblemente ocupada @LeanBitLab la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
LeanBitLab/LeanType#713 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 54/100
LeanBitLab/LeanType#717 ·
Los mantenedores suelen responder en 1 día
-
Crush ReportPosiblemente ocupada @LeanBitLab la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 20/100
LeanBitLab/LeanType#715 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Text Expander/cursor-handling bugPosiblemente ocupada @LeanBitLab la tomó hace 3 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
LeanBitLab/LeanType#703 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
LeanBitLab/LeanType#699 ·
Los mantenedores suelen responder en 1 día
Todos los issues de LeanBitLab/LeanType
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Kotlin/kotlinx-io#529 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
mcnaveen/health-connect-webhook#110 ·
Los mantenedores suelen responder en 1 día
-
Delete all aboveAbiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
mjaakko/NeoStumbler#1307 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
No Wallpaper: Black and white theme changes makes fonts look weird on Home screen and App listAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
tanujnotes/Olauncher#770 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100