Skip to content

Fix Vietnamese Telex tone/shape-key bugs, correct accent detection for non-Italian locales, seed next-word predictions - #301

Closed
Oxydox wants to merge 12 commits into
palsoftware:mainfrom
Oxydox:main
Closed

Oxydox wants to merge 12 commits into
palsoftware:mainfrom
Oxydox:main

Conversation

@Oxydox

@Oxydox Oxydox commented Sep 6, 2026

Copy link
Copy Markdown

This PR fixes several real bugs found and verified through extensive day-to-day use of the Vietnamese Telex layout, plus one fix to the (locale-agnostic) suggestion engine and a next-word prediction improvement.

Telex fixes (VietnameseTelexProcessor.kt):

Tone marks landed on the wrong vowel in ao/eo diphthongs (e.g. "nao"+f → "naò" instead of "nào"), and in closed syllables like oan/oat (e.g. "toan"+s → "tóan" instead of "toán").
Non-adjacent letters incorrectly merged into đ (typing "d","e","s","t","r" would corrupt into duplicated/dropped letters).
Shape keys (a/e/o doubling) could reach back through an already-closed syllable coda and corrupt an earlier vowel (e.g. "mam"+"a" → "maam" instead of staying literal).
Added onset-validity checking so common English words typed while Telex is active (e.g. "wolf", "zoo", "stress", "straight") no longer get incorrectly converted in the first place.
Two letters that don't fit an already-converted word (e.g. an abbreviation like "đky", or a plain consonant after a complete word like "biết"+n) now insert literally after the word instead of corrupting the whole thing back to raw keystrokes. An earlier version of this fix used a broader rollback mechanism that also blocked legitimate tone-cycling on any word ending in a common coda (t/ch/ng/etc.) — replaced with narrower tracking of only explicitly-cancelled tones (same tone key pressed twice), so normal cycling (e.g. "biết" → "biệt" → "biết") always works.
đ's third-key-press escape now reverts fully to literal dd, matching how the other shape keys already escape (e.g. ô + o → oo). Previously it appended a literal d instead (đd). Confirmed against real device behavior before changing — this changes what one existing test expected, updated accordingly.

All changes verified against the full existing test suite (zero regressions) plus a broad set of real Vietnamese words with varied onsets/codas, and cross-checked against real typing patterns rather than synthetic examples alone.

Suggestion engine (SuggestionEngine.kt):

The "does this candidate have an accent" check was hardcoded to a small set of Italian-only accented characters, so it silently never fired for most Vietnamese diacritics (missed ô, ơ, ư, â, ă, đ, and any combined tone+shape mark). Replaced with the general NFD-based accent-stripping check already used elsewhere in the same file, so it works correctly for any language, not just Italian.

Next-word prediction (UserNGramStore.kt):

Previously started with zero data for every new install — no shipped bigram model at all. Added a small seed set of ~130 common Vietnamese word-pairs, inserted at a low baseline count so real usage naturally overtakes it over time.

fix(telex): tone placement on ao/eo clusters, d-adjacency, closed-syllable vowel reach-through
Refactor VietnameseTelexProcessor to handle non-Vietnamese syllables and improve tone application logic.
Added a method to pre-populate Vietnamese bigrams for next-word suggestions, ensuring new installs have initial predictions. This method seeds common word pairs with a low baseline count to encourage learning from user input.
Removed bailoutSyllable state management and replaced it with toneCancelledPrefix to handle tone cancellation more effectively. Updated logic in rewrite and applyToneKey methods to accommodate the new state.
test: fix window-visibility timing in CandidatesBarControllerTest

setContentView() was called after the activity was already visible,
so Robolectric never dispatched windowVisibility=VISIBLE to the new
content view, failing the stricter isActuallyRendered() check added
in the latest upstream release. Reordered to setContentView before
the activity becomes visible, matching real Android lifecycle order.
Updated activity controller setup in test to ensure proper visibility and rendering of input view.
Updated window visibility dispatch logic in test.
Ensure window visibility is set for system-level rendering.
@Oxydox Oxydox closed this Sep 13, 2026
@pzauner

pzauner commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

@Oxydox please tell me when you are ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants