Conversation
Distinguish unavailable surrounding text from an actual field start and consult the editor's requested caps modes only on the fallback path. Preserve context-independent character caps, phantom-space word boundaries, and language-aware cached-context behavior. Add real-editable InputConnection regressions and exercise the InputLogic implicit sentence-caps path for native and web editors. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RichInputConnection.getCursorCapsModecurrently turns an unavailable surrounding-text read into an empty string: directly for web editors, or via the cleared cache after a failed native-editor reload.CapsModeUtilsthen interprets that empty string as an affirmative sentence start.A synthetic editor containing
hello there, with its cursor at 11, reproduces the defect whengetTextBeforeCursorreturns null (or an empty result despite a known nonzero cursor). The editor itself reports no caps. The current implementation returnsCAP_MODE_SENTENCESinstead, including throughInputLogic.getCurrentAutoCapsStatewhen auto-caps adds a sentence request to an ordinary text field.Change
InputConnection.getCursorCapsModewith only the requested caps bits; its result is masked to those bits.CapsModeUtilshandling for available context unchanged, including real field starts and German punctuation rules. Healthy native cached-text queries perform no additional IPC.The fallback adds a caps RPC only when context is unavailable and context-dependent modes are requested. Without surrounding text, a pending phantom space alone cannot establish that preceding punctuation ended a sentence; the fallback deliberately does not guess.
Verification
Test-first: the 24 focused tests produced 16 assertion failures before the production change, including both actual InputLogic integration cases returning 16384 instead of 0. The same 24 tests pass after the change.
The dedicated fixture uses a real editable
BaseInputConnection: text and cursor remain present while only the surrounding-text response is made unavailable. Coverage includes native/web null and empty responses, unknown/stale cursor positions, reload recovery, requested-mode masking, character/word/sentence caps, phantom spaces, composing text, local language rules, and healthy-cache IPC counts.Nearby verification with JDK 21 and Android SDK:
Fresh XML results: 148 passed, 1 existing ignored Hangul test, 0 failures/errors across 149 tests. The offline debug variant was blocked before tests by the existing flavor minSdk 21 /
graphics-path:1.1.0minSdk 23 manifest mismatch; no dependency or build configuration was changed.Scope
This fixes the demonstrated missing-context fallback defect, not every report of capitalized suggestions. The exact WhatsApp/Discord user scenario has not been reproduced on a device; no device validation or APK build is claimed. Dictionary casing, acronyms/proper nouns, suggestion/contraction ranking, manual Shift/Caps Lock, other cursor bookkeeping, and nonempty truncated-context heuristics are unchanged.
One independent code-and-tests commit, based on upstream
b718d832c41ba01e1cce613f14e6209c279e9d17.