-
Notifications
You must be signed in to change notification settings - Fork 550
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
Error after 2 users type simultaneously in collab editor #342
Comments
Paragraphs are separated by newlines, so you could try extracting the text string from the document, then counting the number of newlines (perhaps counting consecutive newlines as one).
If you have the ZefyrController, you can extract the text string and count paragraphs with something like:
_controller.document.toPlainText().split(r'\n+').length
You may want to do something to account for embedded objects (e.g., images and horizontal separators). They should appear in the text string as EmbedNode.kPlainTextPlaceholder (character 0x200b).
_controller.document.toPlainText().split(r'[\n\u200b]+').length
And since there is always at least 1 newline at the end of a document, you may want to subtract that from the result:
_controller.document.toPlainText().split(r'[\n\u200b]+').length - 1
I have not tested any of this...
… On Jun 12, 2020, at 7:19 AM, Albert- Jan Plate ***@***.***> wrote:
Hi all! Currently working on a collab editor with Zefyr but everytime 2 users are typing simultaneously it crashes. However when the two devices type separately everything works as expected.
Steps to Reproduce
Create a socket.io which emits changes
Have 2 people type simultaneously
Both editors go out of sync, and edits are not displayed anymore on the other device
My code
Following code is where the log points to:
socket.on('editor_change', (data) {
Map list = json.decode(data);
ChapterChange change = ChapterChange.fromMap(list);
if (change.user != uniqueId) {
Delta delta = Delta.fromJson(json.decode(change.change));
_controller.compose(delta, source: ChangeSource.remote);
}
});
Logs
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: 'package:notus/src/document/node.dart': Failed assertion: line 237 pos 12: 'index == 0 || (index > 0 && index < length)': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
#2 ContainerNode.insert (package:notus/src/document/node.dart:237:12)
#3 NotusDocument.compose (package:notus/src/document.dart:231:15)
#4 ZefyrController.compose (package:zefyr/src/widgets/controller.dart:87:17)
#5 _EditorPageState.initState.<anonymous closure> (package:editor/test.dart:83:21)
#6 EventEmitter.emit.<anonymous closure> (package:socket_io_common/src/util/event_emitter.dart:52:14)
#7 List.forEach (dart:core-patch/growable_array.dart:282:8)
#8 EventEmitter.emit (package:socket_io_common/src/util/event_emitter.dart:51:11)
#9 Function._apply (dart:co<…>
Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale en-NL)
• Flutter version 1.17.3 at
/Users/albertjanp/Documents/Development/Software/flutter
• Framework revision b041144f83 (8 days ago), 2020-06-04 09:26:11 -0700
• Engine revision ee76268252
• Dart version 2.8.4
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#342>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEDZRDYIZXNERNN7EEGNXQ3RWIFMHANCNFSM4N4HU5MA>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi all! Currently working on a collab editor with Zefyr but everytime 2 users are typing simultaneously it crashes. However when the two devices type separately everything works as expected.
Steps to Reproduce
My code
Following code is where the log points to:
Logs
The text was updated successfully, but these errors were encountered: