super_editor
super_editor copied to clipboard
[BUG] - IME Chinese composing crash when deleting character at the end of text
Package Version Latest main
User Info individual
To Reproduce Steps to reproduce the behavior:
- Place the caret at the end of an existing line in the text editor.
- Start composing Chinese characters (using IME)
- Press Backspace to delete the currently composing character (e.g., after typing 'n', where suggestions are displayed but none are selected).
- Press Backspace again to delete the last character before the composition position
Actual behavior
- Throws exception after second Backspace:
======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for PausableValueNotifier<DocumentSelection?>:
Range start 103 is out of text of length 102
'package:flutter/src/services/text_input.dart':
Failed assertion: line 1130 pos 7: 'range.start >= 0 && range.start <= text.length'
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=02_bug.yml
When the exception was thrown, this was the stack:
#2 TextEditingValue._textRangeIsValid (package:flutter/src/services/text_input.dart:1130:7)
#3 TextEditingValue.toJSON (package:flutter/src/services/text_input.dart:1088:12)
#4 _PlatformTextInputControl.setEditingState (package:flutter/src/services/text_input.dart:2475:68)
#5 TextInput._setEditingState (package:flutter/src/services/text_input.dart:2164:15)
#6 TextInputConnection.setEditingState (package:flutter/src/services/text_input.dart:1569:25)
#7 DocumentImeInputClient.setEditingState (package:super_editor/src/default_editor/document_ime/document_ime_communication.dart:157:28)
#8 DocumentImeInputClient._sendDocumentToIme (package:super_editor/src/default_editor/document_ime/document_ime_communication.dart:277:5)
#9 DocumentImeInputClient._onContentChange (package:super_editor/src/default_editor/document_ime/document_ime_communication.dart:87:5)
#10 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:435:24)
#11 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:560:5)
#12 PausableValueNotifier.resumeNotifications (package:super_editor/src/infrastructure/pausable_value_notifier.dart:49:11)
#13 MutableDocumentComposer.onTransactionEnd (package:super_editor/src/core/document_composer.dart:155:24)
#14 Editor._onTransactionEnd (package:super_editor/src/core/editor.dart:331:16)
#15 Editor.endTransaction (package:super_editor/src/core/editor.dart:231:5)
#16 Editor.execute (package:super_editor/src/core/editor.dart:283:7)
#17 CommonEditorOperations.deleteUpstream (package:super_editor/src/default_editor/common_editor_operations.dart:1168:16)
#18 deleteBackward (package:super_editor/src/default_editor/document_ime/supereditor_ime_interactor.dart:733:21)
#19 SuperEditorImeInteractorState._onPerformSelector (package:super_editor/src/default_editor/document_ime/supereditor_ime_interactor.dart:494:12)
#20 DocumentImeInputClient.performSelector (package:super_editor/src/default_editor/document_ime/document_ime_communication.dart:305:22)
#21 DeltaTextInputClientDecorator.performSelector (package:super_editor/src/default_editor/document_ime/ime_decoration.dart:104:14)
#22 ListBase.forEach (dart:collection/list.dart:51:13)
#23 TextInput._handleTextInputInvocation (package:flutter/src/services/text_input.dart:2094:19)
#24 TextInput._loudlyHandleTextInputInvocation (package:flutter/src/services/text_input.dart:1951:20)
#25 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:611:55)
#26 MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:601:55)
#27 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:653:35)
#28 _invoke2 (dart:ui/hooks.dart:363:13)
#29 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
#30 _Channel.push (dart:ui/channel_buffers.dart:136:31)
#31 ChannelBuffers.push (dart:ui/channel_buffers.dart:344:17)
#32 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:802:22)
#33 _dispatchPlatformMessage (dart:ui/hooks.dart:277:31)
(elided 2 frames from class _AssertionError)
The PausableValueNotifier<DocumentSelection?> sending notification was: PausableValueNotifier<DocumentSelection?>#a5e60([Selection] - 2957f784-e548-425d-8ad4-56668876a8ec: 100)
====================================================================================================
Expected behavior
- Composition cancels cleanly
- Previous character deletes normally
Platform macos
Flutter version Flutter 3.32.4
Screenshots
https://github.com/user-attachments/assets/560d50cb-d1b4-4dd1-8ebb-da84aac654b3