Skip to content

Commit

Permalink
Fix: Resolved issue with broken IME composing rect in Windows desktop…
Browse files Browse the repository at this point in the history
… app (#2239)

- Fixed issue where the composing rect would break during IME conversion.
- When the composing region is unknown, the offset is now calculated based on the current selection position.
- Refactored the function to calculate the ComposingRange into a separate function.
  • Loading branch information
agata committed Sep 18, 2024
1 parent 3b3a77f commit d706c96
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,19 @@ mixin RawEditorStateTextInputClientMixin on EditorState
_textInputConnection!.show();
}

TextRange _getComposingRange() {
if (_lastKnownRemoteTextEditingValue != null &&
_lastKnownRemoteTextEditingValue?.composing.isValid == true) {
return _lastKnownRemoteTextEditingValue!.composing;
} else if (textEditingValue.composing.isValid == true) {
return textEditingValue.composing;
} else {
return widget.controller.selection;
}
}

void _updateComposingRectIfNeeded() {
final composingRange = _lastKnownRemoteTextEditingValue?.composing ??
textEditingValue.composing;
final composingRange = _getComposingRange();
if (hasConnection) {
assert(mounted);
final offset = composingRange.isValid ? composingRange.start : 0;
Expand Down

0 comments on commit d706c96

Please sign in to comment.