Skip to content

feat: add mergeImeCompositionHistory config to group IME intermediate states in undo stack#2723

Open
nandin9 wants to merge 1 commit intosingerdmx:masterfrom
nandin9:feat/ime-composition-history
Open

feat: add mergeImeCompositionHistory config to group IME intermediate states in undo stack#2723
nandin9 wants to merge 1 commit intosingerdmx:masterfrom
nandin9:feat/ime-composition-history

Conversation

@nandin9
Copy link
Copy Markdown

@nandin9 nandin9 commented Mar 25, 2026

Description

Currently, when users type using an Input Method Editor (IME) like Chinese Pinyin or Japanese, every intermediate keystroke (composing state) is recorded as a separate step in the History undo stack. This leads to a broken undo/redo experience where pressing Cmd+Z or Ctrl+Z undoes individual pinyin letters instead of the final committed word.

This PR introduces a new configurable feature to group these IME composition states into a single, clean undo step.

Changes Made

  • Added mergeImeCompositionHistory in QuillEditorConfig: A new boolean flag (defaulting to true) allowing developers to control this IME history merging behavior.
  • Added forceMergeNext in History: A new setter in the bottom-layer History class. It utilizes Dart's Future.microtask to automatically and safely reset its state after the current synchronous event loop, ensuring no state leakage to subsequent regular key presses.
  • Intercepted updateEditingValue in RawEditorState: Reads the isComposing state from TextEditingValue and flags the history stack to merge the upcoming delta if the previous state was composing.

Visual Proof (Before & After)

  • Before: Pressing Undo removes intermediate pinyin characters one by one.
video-1774413039976.mp4
  • After: Pressing Undo cleanly removes the entire committed phrase as a single logical step.
video-1774412915619.mp4

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

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.

1 participant