Repository navigation
mixin_markdown_widget: select whole Chinese words on double click - #550
Merged
boyan01 merged 1 commit intoOct 21, 2026
Conversation
Flutter's bundled ICU has no CJK dictionary, so double clicking Chinese text selected a single character. Word selection now asks `word_segmenter`, which uses the platform's segmenter (CFStringTokenizer, system ICU, or Intl.Segmenter) and falls back to `TextPainter.getWordBoundary` when the platform has none. `我们使用Flutter开发桌面应用` now selects `开发` instead of `开`. Adds a dependency on `word_segmenter: ^0.1.0`.
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.
Summary
Stacked on #544. Double clicking Chinese text selected one character because Flutter's bundled ICU has no CJK dictionary. Word selection now asks
word_segmenter(#548) first.word_segmenter: ^0.1.0(already on pub.dev; resolves to the workspace package here).Evidence
Before: the strengthened
markdown_word_selection_test.dartagainst the oldlib/:After: 5/5.
我们使用Flutter开发桌面应用selects我们 / 使用 / Flutter / 开发 / 桌面 / 应用at every offset and from the right half of each word's last character; double click on效selects效果, on桌selects桌面.flutter test(package)icu.dll)libicuuc)flutter analyze: no issues. Not checked by hand in the GUI yet.Merge Danger
Door: two-way
Blast Radius: selection
Only double-click word selection in non-ASCII runs changes. Segments come from platform dictionaries, so the exact word can differ by platform (e.g. macOS splits
很好into很 / 好). Platforms without a segmenter (Android < 31, very old Windows) keep the previous per-character behavior. Releasing the nextmixin_markdown_widgetaddsword_segmenterto consumers' dependency trees.