Conversation
Do not append pending autocorrections to the expansion search buffer. Cover cps corrected to cpp, real cpp triggers, immediate and separator expansion, and undo using the editor input path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Compute matched prefix length from the composing typed word, not a longer or shorter correction. Retain selected-candidate behavior for manual picks and verify prefix, surrounding text, cursor, and selection paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
AsafMah
marked this pull request as draft
September 29, 2026 14:59
Skip expansion when a manually picked word differs from the actual composing word. Preserve same-word and case-only shortcut expansion and undo. Cover prefixed and full regex matches, longer and shorter choices, and suffix-only candidates through the editor path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Return the expansion outcome from commitChosenWord and skip correction metadata and candidate statistics when expansion replaced the candidate. Record editor commitCorrection callbacks in tests; preserve real autocorrection notifications with expansion disabled or unmatched. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
AsafMah
marked this pull request as ready for review
September 29, 2026 15:19
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.
Purpose
Make regex text expansion depend on actual typed text, calculate prefix removal from the composing word, respect deliberate manual suggestion choices, and avoid reporting autocorrections that expansion replaced.
This addresses a reproduced regex configuration related to the report that typing
cpsexpands acppshortcut. A literalcppentry already rejects typedcps; the reporter's original UI/configuration was unavailable, so this does not claim to reproduce every configuration.Reproduction and behavior
__regex__:cpp, typecps, provide pending correctioncpp, then type a space. Previously the matcher synthesizedcpscppand expanded it. Now normal correction producescppwithout triggering the macro.\.pywith an empty configured prefix and separator triggering. Start withkeep ., composepy, provide correctionpython, then type a space. After fixing matching alone, this leftkeep .EXPANDED. Prefix accounting now uses the raw composing word and produceskeep EXPANDED. Shorter corrections are covered too.python,p, orbymust produce the chosen word, not expansion based on the abandonedpy. These cases passed on original upstream but regressed when synthetic matching was removed. Expansion is now bypassed for a different manual choice. Selecting the actual shortcut, including a case-only variation, still expands and can be undone. Regex matching does not fabricate trigger text from a picked candidate either.pythonpreviously sentCorrectionInfo{#7 "py" -> "python"}even though the editor containedkeep EXPANDED. Expansion now reports its outcome to the automatic-commit caller so this uncommitted correction is not announced. Real autocorrection notifications remain intact.Implementation
Four isolated commits, each with editor-path regression coverage:
c9dc2d7a3970335b8ad000755060e2a838949307: match regex shortcuts against actual typed text.c431af241917adb830ad404e905d56ea751c4d2e: measure matched prefixes using the composing word before automatic correction.e8a636b32c5459d7b48d8c125b7d7d907579f0d3: preserve explicit manual choices that differ from the composing word, while retaining same-word/case-only expansion and undo.659c33dd76f67030ac0e74c37ebacfce96578423: return the private expansion outcome and suppress stale automatic-correction metadata/candidate statistics only when expansion replaced the candidate.Only
TextExpanderUtils.kt,InputLogic.kt, andInputLogicTest.ktchange. No branding, dependencies, translations, test skips, or baseline changes.Validation
Run on upstream base
b718d832c41ba01e1cce613f14e6209c279e9d17, using JDK 21.0.12 and the existing Android SDK/build configuration:Fresh JUnit XML: 104 tests, 103 passed, 1 existing ignored Hangul test, 0 failures, 0 errors. The ignored case is
insertLetterIntoWordHangulFails. All 14 added tests were explicitly checked as present and passing.Failing-before-fix evidence was observed for synthetic regex matching, unequal-length prefix removal, manual-choice overriding, and incorrect editor correction metadata. Manual-choice fixtures were also run with the production files verified identical to the original upstream base: the
python/p/byand full-regex cases passed there, establishing the introduced regression. A separately named suffix-onlyychoice exposed a pre-existing related defect that the same manual-choice gate also prevents.Coverage includes actual
cppexpansion and undo in immediate/separator modes, literal/regex behavior, surrounding text and cursor preservation, longer/shorter/same-length manual choices, case-insensitive same-word selection, and real correction notification offset/old/new text with expansion disabled or unmatched. The original two source commits remain unchanged, confirmed by range-diff.Limits
Validation exercises the existing Robolectric InputLogic/editor integration and captures actual
InputConnection.commitCorrectioncalls. No physical-device UI or APK validation was performed for this standalone upstream contribution.