From d706c9654ad29526700e074ae861fa9cc1f2ea0e Mon Sep 17 00:00:00 2001 From: agata Date: Wed, 18 Sep 2024 15:20:57 +0900 Subject: [PATCH] Fix: Resolved issue with broken IME composing rect in Windows desktop 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. --- .../raw_editor_state_text_input_client_mixin.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart b/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart index da56d0f3d..f1132bf03 100644 --- a/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart +++ b/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart @@ -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;