Open
Conversation
Member
|
Can you explain a situation in which this happens? Is this a common issue, or a rare case? Is this where you first load a document that has people actively editing it, and in that case, the cursor might move a bit before you are fully caught-up? When I thought through the cursor protocol, I was originally going to maintain versions on cursors, but then it seemed like we don't need them. I'm wondering if there's a common case where visible cursor jumping is happening that I'm not aware of. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cursor PUTs don't carry any version context. If the server has applied edits the client hasn't seen yet, the position lands on the wrong character and the cursor visibly jumps until the client catches up.
This adds an optional
Versionheader to cursor PUTs. When the server sees it, it grabs the patches between that version and current viaxfSince, then transforms the cursor positions before storing. Same thing simpleton already does to reconcile text edits from clients at different points in history.No
Versionheader means no transform, so existing clients keep working.Changes
client/simpleton-sync.js: expose aversiongetter on the returned object so cursor code can read it.client/cursor-sync.js: accept an optionalget_versioncallback. When provided, its return value is sent as aVersionheader on cursor PUTs.cursor_highlightsgets anattach(simpleton_client)method to wire the two together.server.js: in the cursor PUT handler, if there's aVersionheader, transform the cursor data through intervening patches before storing. The transform lives in a closure at the call site so it can reachget_xf_patchesandOpLog_remote_to_local.client/editor.html,client/markdown-editor.html: callcursors.attach(simpleton)to actually enable the feature in the bundled editors.README.md: updated the cursor example and API docs to includeattach().test/cursor-tests.js: three tests covering stale version rebase, missing version (stored as-is), and current version (no-op).Usage