Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Introduced context for OT. Refactored: History, RemoveOperation, OT and other. #977

Merged
merged 25 commits into from
Jul 6, 2017

Conversation

scofalik
Copy link
Contributor

@scofalik scofalik commented Jun 22, 2017

Suggested merge commit message (convention)

Feature: OT uses context information for better conflict resolving.

This includes refactoring of: History, RemoveOperation, operational transformation algorithms, delta transformation algorithms and more.

Context will be used instead of removing deltas from history, which caused bugs in more complicated scenarios. This mostly affects undo algorithms.

BREAKING CHANGE: History API for deleting undone deltas has been removed.
BREAKING CHANGE: deltaTransform#transformDeltaSets is now protected. Use model.Document#transformDeltas instead.


Additional information:

  • RemoveOperation no longer creates $graveyardHolder elements. We are not using $graveyardHolder anywhere anymore.
  • RemoveOperation no longer sets its targetPosition on its own in constructor. targetPosition has to be passed to the constructor instead.
  • Batch#remove now creates multiple RemoveDeltas each with one RemoveOperation instead of one delta with multiple operations.
  • Introduced deltas normalization. Each delta has its set structure, for example MoveDelta has exactly one MoveOperation, SplitDelta has exactly InsertOperation and MoveOperation (or NoOperation) in this order, etc. After delta transformation using OT algorithms (default case), MoveOperation may get split into two, creating "not normal" deltas. For example SplitDelta with InsertOperation and two MoveOperations. This is normalized to one SplitDelta (insert + first move) and one MoveDelta (second move).
  • If RemoveOperation has been undone, it is not treated as "always more important" than the other operation, during RemoveOperation transformation.
  • Removed deltas priority. They were used to change isStrong flag (now context.isStrong). In this new approach it might make too much mess. Deltas priority was supposed to fix some problems in delta transformations. After refactoring and removing this mechanisms no tests fail anyway. Maybe some of problems were fixed along the way, maybe they are more hidden. Anyway there will be a followup to revise all delta transformation special cases, so we will return to that problem later.

@scofalik
Copy link
Contributor Author

scofalik commented Jun 22, 2017

* @returns {Boolean} `true` if given {@link ~Range range} boundaries are contained by this range, `false` otherwise.
*/
containsRange( otherRange ) {
return this.containsPosition( otherRange.start ) && this.containsPosition( otherRange.end );
containsRange( otherRange, strict = true ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default of a boolean flag should be false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to pass false as a param.

Copy link
Contributor Author

@scofalik scofalik Jun 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've seen you commented on it previously. I understand your point. My point was that this is creating double negation (nonStrict == false) which is sometimes confusing to read and understand when the code is longer (which is not the case here, but still I don't like having negation in variable/parameter name).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. So maybe weak?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that loose is a better term.

@scofalik
Copy link
Contributor Author

I've added some more commits but messed up a bit and rebased instead of merge with master, so sorry for this :).

@scofalik
Copy link
Contributor Author

I've created all needed PRs in other repos.

@scofalik
Copy link
Contributor Author

I found a bug in undo during manual testing, fixing it right now.

…oes not set `targetPosition` on its own.

Added: `RemoveOperation#isPermanent`.
Changed: `Batch#remove` now creates separate delta for each `RemoveOperation` instead of creating one delta with multiple operations.
Added: `isPermanent` parameter in `Batch#remove`.
…for deltas transformation (instead of `deltaTransform.transformDeltaSets` which is protected).
…rsed()` were incorrect after `RemoveOperation` no longer creates `$graveyardHolder`.
…sformations since `RemoveOperation` no longer creates `graveyardHolder`.
…eOperation` x `MoveOperation` transformation.
…ds on document.history, better context setting, deltas normalization.
…done to operations and deltas transformations.
@scofalik
Copy link
Contributor Author

scofalik commented Jul 5, 2017

Okay, I've rewritten and fixed a lot of stuff in deltas transformations and operations transformations. For now it is okay, however I will create several followups.

@scofalik
Copy link
Contributor Author

scofalik commented Jul 5, 2017

I've updated related PRs and checked that all branches together work fine.

@scofalik
Copy link
Contributor Author

scofalik commented Jul 5, 2017

I've added follow up issues.

@Reinmar
Copy link
Member

Reinmar commented Jul 5, 2017

I pushed remove-refactor to ckeditor5 with the branches setup.

@Reinmar
Copy link
Member

Reinmar commented Jul 5, 2017

Please resolve conflicts in ckeditor/ckeditor5-undo#63.

// Here we do not need to worry that newTargetPosition is inside moved range, because that
// would mean that the MoveOperation targets into itself, and that is incorrect operation.
// Instead, we calculate the new position of that part of original range.
// // If MoveOperations has common range it can be one of two:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it left like this intentionally?

@@ -52,12 +53,11 @@ import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';
* `a` by `b` and also `b` by `a`. In both transformations the same operation has to be the important one. If we assume
* that first or the second passed operation is always more important we won't be able to solve this case.
*
* @external module:engine/model/model.operation
* @protected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove this because it creates a precedence that we have a protected export. We should rather invest in marking internal modules all across the code.

} );
return makeMoveOperationsFromRanges( a, ranges, newTargetPosition );

// // Map transformed range(s) to operations and return them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here again – was it left intentionally?

}

/**
* Two ranges are equal if their {@link #start start} and
* {@link #end end} positions are equal.
* Two ranges are equal if their {@link #start start} and {@link #end end} positions are equal.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to type #start start. Just leave the property or class name unless you want to change the wording a bit.

@Reinmar Reinmar merged commit 481eb9b into master Jul 6, 2017
@Reinmar Reinmar deleted the remove-refactor branch July 6, 2017 16:03
Reinmar added a commit to ckeditor/ckeditor5-undo that referenced this pull request Jul 6, 2017
Internal: Undo algorithms were simplified thanks to changes in the model. See ckeditor/ckeditor5-engine#977.
@Reinmar
Copy link
Member

Reinmar commented Jul 6, 2017

Please close tickets which should be closed now (and please cross-link them for the future reference).

Also, please check issues that you assigned to yourself, whether you're still working on them.

@scofalik
Copy link
Contributor Author

scofalik commented Jul 7, 2017

The commented out code was left there by mistake. I already pushed a commit to master fixing it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants