KB1RD / matrix-notepad

A buggy way to collaborate on text documents using the Matrix protocol. When it works, consider this the Matrix Console of collaboration!
https://matrix-notepad.kb1rd.net/
GNU General Public License v3.0
67 stars 1 forks source link

Core algorithm bugs #20

Closed friedger closed 4 years ago

friedger commented 4 years ago

Original text:

Collaborative Text Editing

This document described

Hello

Result for the other user:

Collaborative TtinThis docuentm describedHello
KB1RD commented 4 years ago

Thank you for pointing this out. I'm actually aware of issues like these, but I haven't opened an issue yet. The issues are due to bugs in the core algorithm and I've opened an issue here to keep track of these. In short, I'm not fixing these issues in the current algorithm version because introducing conflict resolution creates major changes. I'm very close to finishing this new version (but I've said that for like a month) and then I'll work on introducing it into the Notepad and writing unit tests. I haven't been able to maintain any of my projects much over the last few months because I've had a ton of schoolwork.

The issues that you encountered are not due to empty lines or cursor moving specifically, though. The algorithm just receives where text insertions/removals are and translates these into Logoot positions to be sent over Matrix. The algorithm keeps track of which positions in the text editor map onto which Logoot positions. The problem is that sometimes its record of where all the text is gets out of sync with what's actually on the screen. That's what's happening here :)

KB1RD commented 4 years ago

AFAIK, v0.2.2 fixes them all. The trick that I've found works well is to run pseudorandom "practical" tests on the algorithm while in development. That way, even if I miss something that code coverage doesn't catch before release, the practical tests will break the algorithm by brute force. Feel free to re-open if other algorithm issues are found.