You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System for synchronizing neural prediction context with cursor position. When user moves cursor mid-word, the prediction system rebuilds state from InputConnection to enable accurate predictions and proper deletion of both prefix and suffix when selecting a suggestion.
Normalized matching for prediction lookup, raw character count for deletion:
val (normalizedPrefix, rawPrefix) = extractWordPrefix(beforeText, language)
// Use normalized for prediction
predictions = wordPredictor.predict(normalizedPrefix)
// Use raw for deletion (preserves actual char count)
ic.deleteSurroundingText(rawPrefix.length, rawSuffix.length)
Edge Cases
Case
prefix
suffix
Behavior
Cursor at end: hello|
"hello"
""
Normal predictions
Cursor mid-word: hel|lo
"hel"
"lo"
Delete both on select
Cursor at start: |hello
""
"hello"
Clear predictions
After space: hello |
""
""
Next-word predictions
After emoji: hi 👋 |
""
""
Reset prediction
Numbers: test|123
"test"
""
Numbers break word
Contraction: don'|t
"don'"
"t"
Treated as single word
Language Handling
Language Type
Behavior
Space-delimited (Latin)
Standard word boundary detection
CJK (Chinese, Japanese, Thai)
Skip cursor sync entirely
RTL (Arabic, Hebrew)
Normal - InputConnection is logical order
German compounds
Treated as single word
French elision (l'homme)
Single unit treatment
Performance
Debouncing: 100ms delay prevents rapid fire during drag selection
IPC Optimization: Single call per direction, max 50 chars