-
Notifications
You must be signed in to change notification settings - Fork 5
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
Direct sync #11
Merged
Merged
Direct sync #11
Conversation
This file contains 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
paulsonnentag
force-pushed
the
clean-transactions
branch
2 times, most recently
from
April 24, 2024 06:56
2f73c6a
to
3a4a696
Compare
paulsonnentag
force-pushed
the
clean-transactions
branch
from
April 24, 2024 07:02
3a4a696
to
eadd7d4
Compare
The keyboard shortcuts for undo/redo have inconsistent behaviours across platforms so we use buttons that trigger undo / redo commands in codemirror instead
Overall looks great, enormously simplifies things! The only thing I think this PR needs is an assertion in the cypress tests that after all the undo/redo stuff has happened the state of the document (automerge document that is) is what we would expect. |
That's a good point. I will add that |
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.
The current implementation of automerge-codemirror inverts Codemirror transactions to sync the state with an Automerge document, which breaks the history plugin of Codemirror. This was a performance optimization, so we don't need to create a new change for each keystroke and instead can batch multiple keystrokes together. This optimization is no longer necessary because Automerge is fast enough.
This new implementation simplifies this by changing the automerge document directly on each keystroke and remembering the resulting heads. If a remote change comes in, we diff the new version against the stored heads and apply the patches to automerge
I'm also simplifying the API. automerge-codemirror is just a single Codemirror plugin now and doesn't need any external setup anymore. The only thing you need to do is set the initial source to the value of the document at initialization