josephg/ShareJS — Issue #44: Mangled text when multiple people type starting from the same place
Author: laughinghan
Created: 2011-11-14 07:19:11+00:00
State: open

For example, if the textbox is empty and both people start typing at the same time, what they type gets interleaved, resulting in mangled text, when the desired behavior is that one complete sentence comes after the other.

This might not be quite a bug, the OT algorithm might be working correctly, but this is still an issue. EtherPad, notably, behaves correctly in this situation, and I don't think it's just because it has higher latency due to lack of WebSockets.

The fix is probably to be smarter about where to put the cursor after applying a remote op. What is currently happening, is that if the cursor is at the end of a line, and a remote op inserts something at the end of the line, the cursor comes after what was inserted. I think that if instead, what the remote op inserts comes after the cursor, then rather than interleaving, text inserted remotely should build up further and further away from text being inserted locally.