Skip to content

fix(input): segment Thai composing text by word boundaries - #2531

Open
Scott-Nx wants to merge 1 commit into
HeliBorg:mainfrom
Scott-Nx:l10n/thai
Open

fix(input): segment Thai composing text by word boundaries#2531
Scott-Nx wants to merge 1 commit into
HeliBorg:mainfrom
Scott-Nx:l10n/thai

Conversation

@Scott-Nx

@Scott-Nx Scott-Nx commented Jun 3, 2026

Copy link
Copy Markdown

Summary

With suggestions enabled, Thai text will remain one long composing word because Thai normally has no spaces between words.

This causes suggestions to use the entire phrase and require pressing Space twice: once to commit the composing text and once to insert the space.

This change segments Thai composing text at word boundaries. Completed words are committed individually, while only the latest word remains composing.

Reproduction

  1. Enable suggestions.
  2. Select a Thai layout.
  3. Type multiple Thai words without spaces, for example ภาษาไทยดี.
  4. Press Space once.

Before this change, the whole phrase remain composing and the first Space only commits it.

After this change, suggestions follow the current Thai word and one Space press inserts the expected space.

Changes

  • Segment Thai composing text using BreakIterator.
  • Commit completed Thai words individually.
  • Keep only the latest word composing.
  • Preserve user-history and n-gram context between committed words.
  • Allow explicit Space insertion after Thai composing text.
  • Leave behavior for other locales unchanged.

Testing

Added tests for:

  • single and multiple Thai word segments
  • user-history and n-gram ordering
  • Space insertion after Thai composing text
  • unchanged English and non-Thai behavior

The affected InputLogicTest and ScriptUtilsTest suites pass.

Source

Follows the investigation in https://codeberg.org/Helium314/aosp-dictionaries/pulls/83.

@henrebotha

Copy link
Copy Markdown
Contributor

Drive-by review: Presumably there are other scripts we may add in future that also behave this way. Would it make sense to replace the Thai-specific hard-coded aspects with a method in app/src/main/java/helium314/keyboard/latin/utils/ScriptUtils.kt, perhaps something like isScriptSpaceSeparated()?

@Scott-Nx Scott-Nx closed this Jun 17, 2026
@Scott-Nx Scott-Nx reopened this Jun 17, 2026
@Scott-Nx

This comment was marked as outdated.

@Scott-Nx
Scott-Nx marked this pull request as ready for review July 17, 2026 12:57
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