memspace / zefyr

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

'package:notus/src/document/line.dart': Failed assertion: line 291 pos 14: 'nextLine != null': is not true. #567

Closed pulyaevskiy closed 2 years ago

pulyaevskiy commented 2 years ago

Occurs on desktop when DEL is pressed at the end of the document (attempting to delete the last newline character).

======== Exception caught by services library ======================================================
The following assertion was thrown while processing the key message handler:
'package:notus/src/document/line.dart': Failed assertion: line 291 pos 14: 'nextLine != null': is not true.

When the exception was thrown, this was the stack: 
#2      LineNode.delete (package:notus/src/document/line.dart:291:14)
#3      ContainerNode.delete (package:notus/src/document/node.dart:259:15)
#4      NotusDocument.compose (package:notus/src/document.dart:243:15)
#5      NotusDocument.delete (package:notus/src/document.dart:133:7)
#6      NotusDocument.replace (package:notus/src/document.dart:161:27)
#7      ZefyrController.replaceText (package:zefyr/src/widgets/controller.dart:66:24)
#8      RawEditorStateSelectionDelegateMixin.textEditingValue= (package:zefyr/src/widgets/editor_selection_delegate_mixin.dart:22:23)
#9      RawEditorState.setTextEditingValue (package:zefyr/src/widgets/editor.dart:759:5)
#10     TextEditingActionTarget.deleteForward (package:flutter/src/widgets/text_editing_action_target.dart:468:5)
#11     _DeleteForwardTextAction.invoke (package:flutter/src/widgets/default_text_editing_actions.dart:113:30)
#12     ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:571:21)
#13     ShortcutManager.handleKeypress (package:flutter/src/widgets/shortcuts.dart:717:38)
#14     _ShortcutsState._handleOnKey (package:flutter/src/widgets/shortcuts.dart:918:20)
#15     FocusManager._handleKeyMessage (package:flutter/src/widgets/focus_manager.dart:1593:32)
#16     KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:832:37)
#17     BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:77:49)
#18     BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:76:47)
#19     _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:389:35)
#20     _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:386:46)
#21     _invoke2.<anonymous closure> (dart:ui/hooks.dart:189:15)
#25     _invoke2 (dart:ui/hooks.dart:188:10)
#26     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#27     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#28     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#29     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)
#30     _dispatchPlatformMessage (dart:ui/hooks.dart:83:31)
(elided 5 frames from class _AssertionError and dart:async)
KeyMessage: KeyMessage([KeyDownEvent#cab43(physicalKey: PhysicalKeyboardKey#7004c(usbHidUsage: "0x0007004c", debugName: "Delete"), logicalKey: LogicalKeyboardKey#0007f(keyId: "0x10000007f", keyLabel: "Delete", debugName: "Delete"), character: null, timeStamp: 13:12:04.811906)])
====================================================================================================