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

Commit

Permalink
Merge bb014d9 into d248712
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik authored Sep 12, 2018
2 parents d248712 + bb014d9 commit 4cf7c40
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/model/operation/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,13 +1220,17 @@ setTransformation( MergeOperation, MergeOperation, ( a, b, context ) => {
// Doing this instead of returning `NoOperation` allows for a correct undo later.
//
if ( a.sourcePosition.isEqual( b.sourcePosition ) && a.targetPosition.isEqual( b.targetPosition ) ) {
const path = b.graveyardPosition.path.slice();
path.push( 0 );
if ( context.bWasUndone ) {
const path = b.graveyardPosition.path.slice();
path.push( 0 );

a.sourcePosition = new Position( b.graveyardPosition.root, path );
a.howMany = 0;
a.sourcePosition = new Position( b.graveyardPosition.root, path );
a.howMany = 0;

return [ a ];
return [ a ];
} else {
return [ new NoOperation( 0 ) ];
}
}

// The default case.
Expand Down
19 changes: 19 additions & 0 deletions tests/model/operation/transform/split.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,25 @@ describe( 'transform', () => {
expectClients( '<paragraph>Foo</paragraph>' );
} );

it( 'text in same position, then undo and redo', () => {
john.setData( '<paragraph>F[]oo</paragraph>' );
kate.setData( '<paragraph>F[]oo</paragraph>' );

john.split();
kate.split();

syncClients();

john.undo();

syncClients();

kate.undo();
kate.redo();

expectClients( '<paragraph>Foo</paragraph>' );
} );

it( 'text in different path', () => {
john.setData( '<paragraph>F[]oo</paragraph><paragraph>Bar</paragraph>' );
kate.setData( '<paragraph>Foo</paragraph><paragraph>B[]ar</paragraph>' );
Expand Down
4 changes: 4 additions & 0 deletions tests/model/operation/transform/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export class Client {
this._processExecute( 'undo' );
}

redo() {
this._processExecute( 'redo' );
}

_processExecute( commandName, commandArgs ) {
const oldVersion = this.document.version;

Expand Down

0 comments on commit 4cf7c40

Please sign in to comment.