fix: composing not tracked, setEditingState kills IME, bracket pairin…#73
Closed
TheMostBlack wants to merge 1 commit into
Closed
fix: composing not tracked, setEditingState kills IME, bracket pairin…#73TheMostBlack wants to merge 1 commit into
TheMostBlack wants to merge 1 commit into
Conversation
…g corrupts text, undo polluted
Owner
|
The architecture has been completely changed for the upcoming update. You can inspect the dev branch for details. The whole text and selection management including undo stack has been moved to rust side and called via FFI. Also an important thing is that, a third buffer has been introduced called _imeProjectionBuffer, which is small text region where the IME sees. Instead of sending whole text on each key press, only the visible region is copied to this IME buffer and send to the IME. The version 10.0.0 is almost done and I'll release it today or tomorrow. You can check the latest updates in the dev branch. |
Owner
|
The new version has been released. You can contribute to the latest branch. I'm closing this outdated PR. |
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
Fix three overlapping issues: line buffer flush delay, untracked IME composing
region, and setEditingState being called during composition, which together
caused text corruption, composing state loss, and undo stack pollution.
Root Causes & Fixes
1. Composing region was completely ignored
currentTextEditingValuealways returned an empty composing region, so theplatform had no idea an IME composition was in progress.
_composingfield synced fromdelta.composingin real time.currentTextEditingValuenow includes the correct composing region, and allTextEditingValueconstructions passcomposing: _composing.2. setEditingState killed the IME session during composition
setEditingStatewhile composing, forcibly terminatingthe IME session.
if (isComposing) return;at the top of_syncToConnection()._safelySyncEditingState()helper that skips syncing when composing.setSelection,setSelectionImmediately,replaceRange) with!isComposing.setEditingStatecalls in_handleInsertionwith_safelySyncEditingState().3. Bracket pairing corrupted IME text state
_handleInsertionperformed bracket pairing (turning(into()) evenduring composition, breaking the IME’s internal text state.
!isComposingprecondition to the bracket pairing logic.Typing
(while composing no longer produces(), and normal behaviorresumes after composition ends.
4. Undo stack was polluted by individual keystrokes during composition
_preComposingSelectionsnapshot at the start of composition._recordInsertionand_recordDeletionare suppressed._recordReplacementrecords only thefinal result as an
InsertOperation.Flutter 3.44 Compatibility
bool onFocusReceived()toDeltaTextInputClient, whichis an abstract method in the interface, causing compilation failure for any
class that
implementsit.CodeForgeControllerfromimplements DeltaTextInputClienttowith DeltaTextInputClient, inheriting default implementations from the mixin.This prevents future Flutter upgrades from breaking the build when new methods
are added to the interface.
onFocusReceived()returningtrue, correctly indicating thatthe controller accepts focus, which is required for normal text input behavior.
(Returning
falsewould prevent the input field from ever receiving focus.)Behavior after fix
(while composing does not trigger bracket pairing.before composition started.