Repository navigation
Correctly restore markers when undoing/redoing transactions - #53
Conversation
Previously, we attempted to associate patches for all markers with every buffer patch. Now, we allow the application of buffer patches to update markers directly. When undoing or redoing a transaction, we additionally restore all markers to the state they had when the transaction was constructed.
Signed-off-by: Max Brunsfeld <[email protected]>
In the previous commits, we snapshotted all markers before every transaction and restored them on undo. This caused markers to not be in the correct state during buffer change events, which changed our contract. Now the state of every marker that is changed destructively by a buffer change is recorded with the buffer change. Additionally, we also restore any markers that were explicitly moved during the transaction. Signed-off-by: Max Brunsfeld <[email protected]>
421f628 to
79dc8e1
Compare
This ensures that manual marker updates are undone in the correct order.
|
@kevinsawicki This should be ready to 🤘 when you're ready to publish. Core specs pass with it but I haven't run a full CI pass. Happy to address anything that comes up once it's published but @maxbrunsfeld and I are feeling pretty good about it. |
|
Awesome, I'm ready to go, want me to merge and publish this? |
|
Shoot, one more change I need to make then yes. We no longer need to change the serialization version. |
This is required because we dropped `markerPatches` from the serialized data for `BufferPatch`, which causes exceptions when deserializing in older versions.
Signed-off-by: Max Brunsfeld <[email protected]>
There was a problem hiding this comment.
We now wrap everything in a transaction so the history always contains the same kind of object. We thought it was required for our first attempt at fixing this, but it ended up being optional. Still, it's a structural improvement so we decided to leave it.
|
@kevinsawicki Okay this is ready. We did a final review and caught one last issue. |
Correctly restore markers when undoing/redoing transactions
|
👍 |
|
This broke some specs in Atom so I unpublished it for now: |
This is a continuation of #52. It fixes issues where markers weren't restored correctly when undoing transactions with multiple changes.
Whenever a buffer change occurs that overlaps or invalidates a marker, we record the previous state of the marker on the patch causing that change. When a buffer patch is undone, we restore any markers that have their previous state saved on the patch object. This replaces a previous approach to synthesizing marker patches ahead of time that was breaking down in the presence of multiple changes.
Fixes atom/bracket-matcher#110