Implement user cursor and selection tracking #260
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #59.
Clients broadcast own location (focused cell, cursor position/selection) whenever it changes and we show colorful indicators of that. Additionally the user can follow another one, so that they automatically move around together (:cat: !!).
Design
Whenever user location changes we send it to the LV and broadcast to other clients via the
session
topic. We then handle the locations accordingly on the client side. Note that as opposed to text deltas, we don't pass/transform the locations via the session process and that's intentional. When it comes to cursor positions we want to make sure the intermediate states when typing look fine and that eventually we show the actual position. Under low latency, transforming cursor positions has no benefits, and under high latency both approaches may show displaced cursor in intermediate states. By simply broadcasting the locations we don't overflow the session process with additional messages and also avoid a ton of complexity.Also note that if there is just a single user we simply don't send any reports, so there are no implications whatsoever.
Demo
cursors.mp4