Skip to content

Fix Pinyin input while preserving folds, read-only sections, and undo - #322

Open
nausharipov wants to merge 4 commits into
mainfrom
codex/pinyin-composition-fixes
Open

nausharipov wants to merge 4 commits into
mainfrom
codex/pinyin-composition-fixes

Conversation

@nausharipov

Copy link
Copy Markdown
Collaborator

This is a modified replacement for #319 by @FeodorFitsner. It retains both original commits that fixed Chinese Pinyin composition in Chrome. It also addresses the loss of hidden text and read-only section markers when an IME updates the editor. This addresses #126.

What changed

  • Map IME edits from visible text back to the full document. Composing below a folded block preserves its body and fold state.
  • Apply read-only checks to composition and commit, including when Chrome retries a rejected edit by sending only a composing range.
  • Record a committed candidate as one undoable edit. Undo restores the pre-composition text and selection. Canceling composition preserves pending redo.
  • Remove the constructor log that printed the initial document in release builds.

Verification

  • All 292 tests passed with FVM Flutter 3.50.1 and Dart 3.14.0, including five new regression tests.
  • Tested in Chrome 158.0.8127.37 on macOS 26.4.1 using the native Pinyin – Simplified keyboard. Typing ni opened the candidate list. Arrow keys moved the highlight, Space committed the selected character, and selecting 你 by number worked both in plain text and below a fold.
  • Verified one-step Undo and Redo, unfolded the original method body after commit, and confirmed that attempts to edit a protected section left its text and markers intact.

Screenshots

macos-pinyin-candidate-window pinyin-folding-and-read-only-comparison

FeodorFitsner and others added 3 commits March 3, 2026 09:54
- 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
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