-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix MarkerOperation x MoveOperation OT for undo cases #17071
Conversation
…ultiple ranges before the reference range.
…ving undo and real-time collaboration, which earlier lead to `model-nodelist-offset-out-of-bounds` error.
This PR introduces new way to handle To ensure proper transformation, I introduced breaking This is necessary to correctly handle a case like this, and similar. Assume
If we (re)move
Which is natural and correct. However, if during the same transformation process, the marker operation is transformed by reinsert, then we end up with:
We had this and similar cases already covered, but current solution failed for more complex scenarios. Current solution directly saved
The problem is that these paths were not updated during transformation process. If for some reason (e.g. conflict resolution during RTC OT) some part of this paragraph was not returned during undo process, the saved paths may point to non-existing offsets:
Now, instead of saving ranges, we will create additional The difference is that you cannot have multiple ranges for one marker. If we create multiple
With multiple marker operations approach, the original
At the end of transformation process, we will handle these partial marker operations. As I mentioned, we want to have just one marker operation in the end. For each partial marker operation:
|
// If ranges are not starting/ending at the same position there is no point in looking further. | ||
break; | ||
} | ||
for ( let i = refIndex - 1; i >= 0; i-- ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a bug here, we go "left" in the array, so we should decrement i
.
…n some scenarios involving real-time collaboration, which earlier led to `model-nodelist-offset-out-of-bounds` error.
…sh in some scenarios where two users removed bigger intersecting part of the content and used undo.
…h when a user pressed enter key multiple times, then merged them back, then undone all the changes. Closes #9296.
I've wrapped unit tests from |
This PR includes four fixes. I already described the first one. Although that fix is complex and wide, I have very strong confidence that it is correct. There are three more fixes. Fix (2): c5a614e This fix makes it so that The side effect of this change is that sometimes the content may not be recovered exactly as we expected -- i.e. two elements will be removed instead of one, or we would expect an "enter" between some text (so, we get I have lower confidence towards this fix. It fixes one of the issues, and it also fixes an issue found by QA team when testing fix (1). Also, all unit tests were passing. But I assume it was done like this for a reason and we might not know about some scenario, where it made sense. But it may be only to provide better UX during undo (as described above). Also, there is a "mirror case" in Fix (3): 4a9d71d This fix is more straightforward as it appeared that earlier solution lacked transformation of one of the Before this change, the Fix (4): 471390b This causes a special case in During OT/undo when some nodes might have been removed, or splits may have happened, sometimes merge operation starts to target into inside of the element. This is a temporary situation for the merge operation and as the merge operation is further transformed, the target position should eventually end up pointing to an end of target element. The special case was applied always when the merge operation was targeting into inside of an element instead of its end. It appears that this assumption was rather not correct, because in the case I wanted to fix, it caused an error later during other transformations. As you can see, I removed That unit test was still green, even after removing This gives me a bit more confidence towards this fix, but it is similar to fix (2) where we change rules when we apply a fix. I still have more confidence than in fix (2) but less than for fix (1) or (3). The unit test I described above is |
For clarity, below issues should be fixed by this PR:
|
Suggested merge commit message (convention)
Fix (engine): Fixed incorrect marker handling in some scenarios involving undo and real-time collaboration, which earlier lead to
model-nodelist-offset-out-of-bounds
error.Fix (engine): Fixed incorrect handling of merge changes during undo in some scenarios involving real-time collaboration, which earlier led to
model-nodelist-offset-out-of-bounds
error.Fix (engine): Fixed conflict resolution error, which led to editor crash in some scenarios where two users removed bigger intersecting part of the content and used undo.
Fix (engine): Fixed incorrect undo behavior leading to an editor crash when a user pressed enter key multiple times, then pressed backspace that many times, then undone all the changes. Closes #9296.