Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] cannot input anything when start a new line #66

Closed
forrestsocool opened this issue Apr 13, 2023 · 2 comments
Closed

[Bug] cannot input anything when start a new line #66

forrestsocool opened this issue Apr 13, 2023 · 2 comments
Assignees
Labels
bug Something isn't working editor features related to the rich-text editor

Comments

@forrestsocool
Copy link

Bug Description

On windows platform,input Chinese using Sougou IME,I can input only one line sentences,when I start a new line,I cannot input anny thing. At this time, I can see the error show in the Android Studio logs:

======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for ValueNotifier<Selection?>:
Range end 7 is out of text of length 1
'package:flutter/src/services/text_input.dart':
Failed assertion: line 973 pos 12: 'range.end >= 0 && range.end <= 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=2_bug.md

When the exception was thrown, this was the stack:
#2 TextEditingValue._textRangeIsValid (package:flutter/src/services/text_input.dart:973:12)
#3 TextEditingValue.toJSON (package:flutter/src/services/text_input.dart:927:12)
#4 _PlatformTextInputControl.setEditingState (package:flutter/src/services/text_input.dart:2267:13)
#5 TextInput._setEditingState (package:flutter/src/services/text_input.dart:1955:15)
#6 TextInputConnection.setEditingState (package:flutter/src/services/text_input.dart:1361:25)
#7 _AppFlowyInputState.attach (package:appflowy_editor/src/service/input_service.dart:120:9)
#8 _AppFlowyInputState._onSelectionChange (package:appflowy_editor/src/service/input_service.dart:286:7)
#9 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:381:24)
#10 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:495:5)
#11 _AppFlowySelectionState.updateSelection (package:appflowy_editor/src/service/selection_service.dart:236:22)
#12 EditorState.updateCursorSelection (package:appflowy_editor/src/editor_state.dart:111:32)
#13 EditorState.apply. (package:appflowy_editor/src/editor_state.dart:158:15)
#14 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#15 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1227:9)
#16 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1076:5)
#17 _invoke (dart:ui/hooks.dart:145:13)
#18 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
#19 _drawFrame (dart:ui/hooks.dart:112:31)
(elided 2 frames from class _AssertionError)
The ValueNotifier<Selection?> sending notification was: ValueNotifier<Selection?>#40104(start = path = [14], offset = 0, end = path = [14], offset = 0)

flutter: [DEBUG][editor]: 2023-04-13 14:36:06.236681: Seal history item
flutter: [DEBUG][input]: 2023-04-13 14:36:07.152556: (TextEditingDeltaNonTextUpdate#ce5a1(oldText:
flutter: 中文输入第一行
flutter: , selection: TextSelection.collapsed(offset: 7, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 7, end: 7)))
flutter: [DEBUG][input]: 2023-04-13 14:36:07.152556: (TextEditingDeltaInsertion#4f401(oldText:
flutter: 中文输入第一行
flutter: , textInserted: 中文输入法, insertionOffset: 7, selection: TextSelection.collapsed(offset: 12, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 7, end: 12)))
flutter: [DEBUG][input]: 2023-04-13 14:36:07.158540: (TextEditingDeltaNonTextUpdate#06122(oldText:
flutter: 中文输入第一行中文输入法
flutter: , selection: TextSelection.collapsed(offset: 12, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1)))
flutter: [DEBUG][input]: 2023-04-13 14:36:08.531108: (TextEditingDeltaNonTextUpdate#ffc92(oldText:
flutter: 中文输入第一行中文输入法
flutter: , selection: TextSelection.collapsed(offset: 12, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 12, end: 12)))
flutter: [DEBUG][input]: 2023-04-13 14:36:08.532104: (TextEditingDeltaInsertion#7943c(oldText:
flutter: 中文输入第一行中文输入法
flutter: , textInserted: 阿达撒发生的就分手, insertionOffset: 12, selection: TextSelection.collapsed(offset: 21, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 12, end: 21)))
flutter: [DEBUG][input]: 2023-04-13 14:36:08.537091: (TextEditingDeltaNonTextUpdate#02319(oldText:
flutter: 中文输入第一行中文输入法阿达撒发生的就分手
flutter: , selection: TextSelection.collapsed(offset: 21, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1)))

======== Exception caught by services library ======================================================
The following StateError was thrown during method call TextInputClient.updateEditingStateWithDeltas:
Bad state: No element

When the exception was thrown, this was the stack:
#0 Iterable.first (dart:core/iterable.dart:624:7)
#1 TextTransaction.insertText (package:appflowy

How to Reproduce

  1. run this project in windows system
  2. input one line Chinense using IME like SouGou
  3. press ENTER to start a new line
  4. you cannot input anything anymore

Expected Behavior

can input when change line

Operating System

Windows

AppFlowy Editor Version(s)

0.1.6

Screenshots

No response

Additional Context

No response

@annieappflowy
Copy link
Collaborator

Likely related to AppFlowy-IO/AppFlowy#1756

@forrestsocool
Copy link
Author

in file InputSearvice.dart, I added a log to see what is the difference between English and Chinese when start a new line.

@override
 void attach(TextEditingValue textEditingValue) {
   if (_textInputConnection == null ||
       _textInputConnection!.attached == false) {
     _textInputConnection = TextInput.attach(
       this,
       const TextInputConfiguration(
         // TODO: customize
         enableDeltaModel: true,
         inputType: TextInputType.multiline,
         textCapitalization: TextCapitalization.sentences,
       ),
     );
   }
  // add my log
   Log.input.debug(textEditingValue.toString());
   _textInputConnection!
     ..setEditingState(textEditingValue)
     ..show();
 }
  • English: first input “English Input” then press "ENTER" key,belows is the related logs
flutter: [DEBUG][ui]: 2023-04-13 16:12:43.918982: TextNode is rebuilding...
flutter: [DEBUG][selection]: 2023-04-13 16:12:43.920872: update cursor area, start = path = [0], offset = 13, end = path = [0], offset = 13
flutter: [DEBUG][input]: 2023-04-13 16:12:43.920872: TextEditingValue(text: ┤English Input
flutter: ├, selection: TextSelection.collapsed(offset: 13, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: [DEBUG][editor]: 2023-04-13 16:12:44.910835: Seal history item
flutter: [DEBUG][ui]: 2023-04-13 16:12:46.268649: Node is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:12:46.268649: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:12:46.269649: TextNode is rebuilding...
flutter: [DEBUG][selection]: 2023-04-13 16:12:46.270646: update cursor area, start = path = [1], offset = 0, end = path = [1], offset = 0
flutter: [DEBUG][input]: 2023-04-13 16:12:46.271643: TextEditingValue(text: ┤
flutter: ├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: [DEBUG][editor]: 2023-04-13 16:12:47.267355: Seal history item

  • Chinese: first input “中文输入法” then press "ENTER" key,belows is the related logs that abnormal
flutter: [DEBUG][input]: 2023-04-13 16:13:39.295218: TextEditingValue(text: ┤中文输入法
flutter: ├, selection: TextSelection.collapsed(offset: 5, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 5))
flutter: [DEBUG][editor]: 2023-04-13 16:13:40.276188: Seal history item
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.826483: Node is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.826483: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.827481: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.828478: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.828478: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.829475: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.830474: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.830474: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.831472: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.831472: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.832468: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.833468: TextNode is rebuilding...
flutter: [DEBUG][ui]: 2023-04-13 16:13:45.834463: TextNode is rebuilding...
flutter: [DEBUG][selection]: 2023-04-13 16:13:45.839450: update cursor area, start = path = [11], offset = 0, end = path = [11], offset = 0
flutter: [DEBUG][input]: 2023-04-13 16:13:45.840448: TextEditingValue(text: ┤
flutter: ├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 5))

======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for ValueNotifier<Selection?>:
Range end 5 is out of text of length 1
'package:flutter/src/services/text_input.dart':
Failed assertion: line 973 pos 12: 'range.end >= 0 && range.end <= 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=2_bug.md

When the exception was thrown, this was the stack: 
#2      TextEditingValue._textRangeIsValid (package:flutter/src/services/text_input.dart:973:12)
#3      TextEditingValue.toJSON (package:flutter/src/services/text_input.dart:927:12)
#4      _PlatformTextInputControl.setEditingState (package:flutter/src/services/text_input.dart:2267:13)
#5      TextInput._setEditingState (package:flutter/src/services/text_input.dart:1955:15)
#6      TextInputConnection.setEditingState (package:flutter/src/services/text_input.dart:1361:25)
#7      _AppFlowyInputState.attach (package:appflowy_editor/src/service/input_service.dart:120:9)
#8      _AppFlowyInputState._onSelectionChange (package:appflowy_editor/src/service/input_service.dart:292:7)
#9      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:381:24)
#10     ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:495:5)
#11     _AppFlowySelectionState.updateSelection (package:appflowy_editor/src/service/selection_service.dart:236:22)
#12     EditorState.updateCursorSelection (package:appflowy_editor/src/editor_state.dart:111:32)
#13     EditorState.apply.<anonymous closure> (package:appflowy_editor/src/editor_state.dart:158:15)
#14     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#15     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1227:9)
#16     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1076:5)
#17     _invoke (dart:ui/hooks.dart:145:13)
#18     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
#19     _drawFrame (dart:ui/hooks.dart:112:31)
(elided 2 frames from class _AssertionError)
The ValueNotifier<Selection?> sending notification was: ValueNotifier<Selection?>#bd9aa(start = path = [11], offset = 0, end = path = [11], offset = 0)
====================================================================================================
flutter: [DEBUG][editor]: 2023-04-13 16:13:46.814955: Seal history item

you can see that the Selection's TextRange start and end index composing: TextRange(start: 0, end: 5)) behavior is different, hope this info is useful.

@annieappflowy annieappflowy added bug Something isn't working editor features related to the rich-text editor labels Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor features related to the rich-text editor
Projects
None yet
Development

No branches or pull requests

3 participants