Skip to content

Commit d40ddd6

Browse files
committed
fix: fix broken image when typing after images
Sync patch from singerdmx#2505
1 parent 9d3952e commit d40ddd6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,12 @@ mixin RawEditorStateTextInputClientMixin on EditorState implements TextInputClie
213213
_lastKnownRemoteTextEditingValue = value;
214214
final oldText = effectiveLastKnownValue.text;
215215
final text = value.text;
216-
final cursorPosition = value.selection.extentOffset;
217-
final diff = getDiff(oldText, text, cursorPosition);
216+
217+
// Dynamically calculate cursor position to resolve misalignment issues when inputting Chinese with Sogou Pinyin.
218+
final effectiveCursorPosition = value.isComposingRangeValid
219+
? value.composing.end
220+
: value.selection.extentOffset;
221+
final diff = getDiff(oldText, text, effectiveCursorPosition);
218222
if (diff.deleted.isEmpty && diff.inserted.isEmpty) {
219223
widget.controller.updateSelection(value.selection, ChangeSource.local);
220224
} else {

0 commit comments

Comments
 (0)