memspace / zefyr

Soft and gentle rich text editing for Flutter applications.
https://zefyr-editor.gitbook.io
2.22k stars 550 forks source link

Exception when moving caret to end of line using physical keyboard (Cmd+Right) #587

Open pulyaevskiy opened 2 years ago

pulyaevskiy commented 2 years ago

Only occurs when the caret is 1 character away from the end of last line in a document.

======== Exception caught by services library ======================================================
The following assertion was thrown while processing the key message handler:
No child at position TextPosition(offset: 4469, affinity: TextAffinity.upstream)
'package:zefyr/src/rendering/editable_box.dart':
Failed assertion: line 243 pos 12: 'targetChild != null'

When the exception was thrown, this was the stack: 
#2      RenderEditableContainerBox.childAtPosition (package:zefyr/src/rendering/editable_box.dart:243:12)
#3      RenderEditor.getLineAtOffset (package:zefyr/src/rendering/editor.dart:885:19)
#4      TextEditingActionTarget.moveSelectionRightByLine (package:flutter/src/widgets/text_editing_action_target.dart:1363:58)
#5      _MoveSelectionRightByLineTextAction.invoke (package:flutter/src/widgets/default_text_editing_actions.dart:274:30)
#6      ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:571:21)
#7      ShortcutManager.handleKeypress (package:flutter/src/widgets/shortcuts.dart:717:38)
#8      FocusManager._handleKeyMessage (package:flutter/src/widgets/focus_manager.dart:1593:32)
#9      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:832:37)