Skip to content

Fix Chinese pinyin input issues in the editor#319

Open
FeodorFitsner wants to merge 2 commits intoakvelon:mainfrom
flet-dev:pinyin-ime-fix
Open

Fix Chinese pinyin input issues in the editor#319
FeodorFitsner wants to merge 2 commits intoakvelon:mainfrom
flet-dev:pinyin-ime-fix

Conversation

@FeodorFitsner
Copy link
Copy Markdown

This PR fixes Chinese pinyin input issues in the editor.

Fixes #126

Root causes:

  1. composing-only updates were ignored in CodeController.value
  2. editor transforms could mutate IME in-progress composition state
  3. custom span rendering bypassed Flutter’s composing-aware rendering
  4. edit diffing could fail on transient out-of-range selections from IME

Changes:

  • Make CodeController accept composing-only updates
  • While composing is active, apply platform value updates directly
  • Use super.buildTextSpan during active composition
  • Clamp old/new selections in Code.getEditResult before diffing
  • Prevent Enter/Tab/Esc shortcut actions during active composition

Tests:

  • Added/updated tests for composing updates, IME commit path, and shortcut behavior
  • Targeted test suite passes

- 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');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

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.

[Windows10 Desktop] IME doesn't work well

2 participants