Repository navigation
Fix Chinese pinyin input issues in the editor - #319
FeodorFitsner wants to merge 2 commits into
Conversation
- preserve composing-only TextEditingValue updates - bypass editor transforms while IME composition is active - use Flutter composing-aware buildTextSpan during composition - clamp selections in Code.getEditResult for transient IME ranges - disable Enter/Tab/Esc shortcuts while composing - add regression tests for composing updates and IME commit
- handle old composing -> new non-composing transition as direct update - keep internal code state synced during composition updates - preserve stable IME behavior on macOS and web
| _code = _createCode(text ?? ''); | ||
| fullText = text ?? ''; | ||
|
|
||
| debugPrint('CodeController initialized with text:\n$text'); |
There was a problem hiding this comment.
debugPrint('CodeController initialized with text:\n$text'); logs full editor content on every controller initialization. This can leak sensitive user code/data and create noisy logs for large documents. Please remove this log (or guard it behind an explicit opt-in debug flag that defaults off).
akvelon#309 (fork #11): with a Chinese IME the editor inserted two characters for one typed character on Windows and dropped characters on web. The controller treats every platform TextEditingValue as a diff of the previous one, but an IME first inserts the keystrokes as a composing region and then replaces that region with the candidate. Four defects, each pinned by a RED test: - composing-only updates were dropped, desynchronizing the engine's IME state (the Windows duplication); - a commit was misclassified as backspace, so the collapsed changed range deleted the composing chars together with the candidate ('} 你' committed as '} n'); - diff-based modifiers fired on composing text ('a(' became 'a()'); - transient out-of-range selections from the platform threw RangeError. Apply platform values verbatim while a composition is active (after syncing the internal Code), ignore Enter/Tab/Escape and the autocomplete popup keys meanwhile, render the composing range with the default composing-aware span builder, and clamp selections in Code.getEditResult before diffing. The Latin input path is unchanged. Adapted from upstream PR akvelon#319 (still open), without its debug print and cosmetic churn.
|
Thanks for this, @FeodorFitsner — treating composing-only updates, in-progress composition state and the composing-aware rendering as four separate root causes is a clean diagnosis. For anyone landing here: the IME/composition class of bug is already handled on the actively maintained fork, arrrrny/zuraffa_code_editor:
The fork exists because |
This PR fixes Chinese pinyin input issues in the editor.
Fixes #126
Root causes:
Changes:
Tests: